<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
(c) The University of Glasgow 2006
(c) The GRASP/AQUA Project, Glasgow University, 1992-1998


        Arity and eta expansion
-}</span><span>
</span><span id="line-8"></span><span>
</span><span id="line-9"></span><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-10"></span><span>
</span><span id="line-11"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}</span><span>
</span><span id="line-12"></span><span>
</span><span id="line-13"></span><span class="hs-comment">-- | Arity and eta expansion</span><span>
</span><span id="line-14"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Core.Opt.Arity</span><span>
</span><span id="line-15"></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#manifestArity"><span class="hs-identifier">manifestArity</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#joinRhsArity"><span class="hs-identifier">joinRhsArity</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#exprArity"><span class="hs-identifier">exprArity</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#typeArity"><span class="hs-identifier">typeArity</span></a></span><span>
</span><span id="line-16"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#exprEtaExpandArity"><span class="hs-identifier">exprEtaExpandArity</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#findRhsArity"><span class="hs-identifier">findRhsArity</span></a></span><span>
</span><span id="line-17"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaExpand"><span class="hs-identifier">etaExpand</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaExpandAT"><span class="hs-identifier">etaExpandAT</span></a></span><span>
</span><span id="line-18"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaExpandToJoinPoint"><span class="hs-identifier">etaExpandToJoinPoint</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaExpandToJoinPointRule"><span class="hs-identifier">etaExpandToJoinPointRule</span></a></span><span>
</span><span id="line-19"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#exprBotStrictness_maybe"><span class="hs-identifier">exprBotStrictness_maybe</span></a></span><span>
</span><span id="line-20"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier">ArityType</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#expandableArityType"><span class="hs-identifier">expandableArityType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#arityTypeArity"><span class="hs-identifier">arityTypeArity</span></a></span><span>
</span><span id="line-21"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#maxWithArity"><span class="hs-identifier">maxWithArity</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#isBotArityType"><span class="hs-identifier">isBotArityType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#idArityType"><span class="hs-identifier">idArityType</span></a></span><span>
</span><span id="line-22"></span><span>   </span><span class="hs-special">)</span><span>
</span><span id="line-23"></span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-28"></span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.html"><span class="hs-identifier">GHC.Core</span></a></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.FVs.html"><span class="hs-identifier">GHC.Core.FVs</span></a></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html"><span class="hs-identifier">GHC.Core.Utils</span></a></span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html"><span class="hs-identifier">GHC.Core.Subst</span></a></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Demand.html"><span class="hs-identifier">GHC.Types.Demand</span></a></span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.html"><span class="hs-identifier">GHC.Types.Var</span></a></span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html"><span class="hs-identifier">GHC.Types.Var.Env</span></a></span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Type</span></span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html"><span class="hs-identifier">GHC.Core.TyCon</span></a></span><span>     </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#initRecTc"><span class="hs-identifier">initRecTc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#checkRecTc"><span class="hs-identifier">checkRecTc</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html"><span class="hs-identifier">GHC.Core.Predicate</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html#isDictTy"><span class="hs-identifier">isDictTy</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html"><span class="hs-identifier">GHC.Core.Coercion</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Coercion</span></span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Multiplicity.html"><span class="hs-identifier">GHC.Core.Multiplicity</span></a></span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html"><span class="hs-identifier">GHC.Types.Var.Set</span></a></span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.html"><span class="hs-identifier">GHC.Types.Unique</span></a></span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier">DynFlags</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Driver.Flags.html#GeneralFlag"><span class="hs-identifier">GeneralFlag</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#gopt"><span class="hs-identifier">gopt</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html"><span class="hs-identifier">GHC.Data.FastString</span></a></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>     </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#lengthAtLeast"><span class="hs-identifier">lengthAtLeast</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-49"></span><span>
</span><span id="line-50"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
              manifestArity and exprArity
*                                                                      *
************************************************************************

exprArity is a cheap-and-cheerful version of exprEtaExpandArity.
It tells how many things the expression can be applied to before doing
any work.  It doesn't look inside cases, lets, etc.  The idea is that
exprEtaExpandArity will do the hard work, leaving something that's easy
for exprArity to grapple with.  In particular, Simplify uses exprArity to
compute the ArityInfo for the Id.

Originally I thought that it was enough just to look for top-level lambdas, but
it isn't.  I've seen this

        foo = PrelBase.timesInt

We want foo to get arity 2 even though the eta-expander will leave it
unchanged, in the expectation that it'll be inlined.  But occasionally it
isn't, because foo is blacklisted (used in a rule).

Similarly, see the ok_note check in exprEtaExpandArity.  So
        f = __inline_me (\x -&gt; e)
won't be eta-expanded.

And in any case it seems more robust to have exprArity be a bit more intelligent.
But note that   (\x y z -&gt; f x y z)
should have arity 3, regardless of f's arity.
-}</span><span>
</span><span id="line-81"></span><span>
</span><span id="line-82"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#manifestArity"><span class="hs-identifier hs-type">manifestArity</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#Arity"><span class="hs-identifier hs-type">Arity</span></a></span><span>
</span><span id="line-83"></span><span class="hs-comment">-- ^ manifestArity sees how many leading value lambdas there are,</span><span>
</span><span id="line-84"></span><span class="hs-comment">--   after looking through casts</span><span>
</span><span id="line-85"></span><span id="manifestArity"><span class="annot"><span class="annottext">manifestArity :: CoreExpr -&gt; JoinArity
</span><a href="GHC.Core.Opt.Arity.html#manifestArity"><span class="hs-identifier hs-var hs-var">manifestArity</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-type">Lam</span></a></span><span> </span><span id="local-6989586621680868095"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680868095"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span id="local-6989586621680868094"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868094"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680868095"><span class="hs-identifier hs-var">v</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; JoinArity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; JoinArity
</span><a href="GHC.Core.Opt.Arity.html#manifestArity"><span class="hs-identifier hs-var">manifestArity</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868094"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-86"></span><span>                        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; JoinArity
</span><a href="GHC.Core.Opt.Arity.html#manifestArity"><span class="hs-identifier hs-var">manifestArity</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868094"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-87"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#manifestArity"><span class="hs-identifier hs-var">manifestArity</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-type">Tick</span></a></span><span> </span><span id="local-6989586621680868090"><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680868090"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span id="local-6989586621680868089"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868089"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tickish Id -&gt; Bool
forall id. Tickish id -&gt; Bool
</span><a href="GHC.Core.html#tickishIsCode"><span class="hs-identifier hs-var">tickishIsCode</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680868090"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">CoreExpr -&gt; JoinArity
</span><a href="GHC.Core.Opt.Arity.html#manifestArity"><span class="hs-identifier hs-var">manifestArity</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868089"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-88"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#manifestArity"><span class="hs-identifier hs-var">manifestArity</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-type">Cast</span></a></span><span> </span><span id="local-6989586621680868085"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868085"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; JoinArity
</span><a href="GHC.Core.Opt.Arity.html#manifestArity"><span class="hs-identifier hs-var">manifestArity</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868085"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-89"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#manifestArity"><span class="hs-identifier hs-var">manifestArity</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><span class="hs-identifier">_</span></span><span>                         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span>
</span><span id="line-90"></span><span>
</span><span id="line-91"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#joinRhsArity"><span class="hs-identifier hs-type">joinRhsArity</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#JoinArity"><span class="hs-identifier hs-type">JoinArity</span></a></span><span>
</span><span id="line-92"></span><span class="hs-comment">-- Join points are supposed to have manifestly-visible</span><span>
</span><span id="line-93"></span><span class="hs-comment">-- lambdas at the top: no ticks, no casts, nothing</span><span>
</span><span id="line-94"></span><span class="hs-comment">-- Moreover, type lambdas count in JoinArity</span><span>
</span><span id="line-95"></span><span id="joinRhsArity"><span class="annot"><span class="annottext">joinRhsArity :: CoreExpr -&gt; JoinArity
</span><a href="GHC.Core.Opt.Arity.html#joinRhsArity"><span class="hs-identifier hs-var hs-var">joinRhsArity</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-type">Lam</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680868084"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868084"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; JoinArity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; JoinArity
</span><a href="GHC.Core.Opt.Arity.html#joinRhsArity"><span class="hs-identifier hs-var">joinRhsArity</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868084"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-96"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#joinRhsArity"><span class="hs-identifier hs-var">joinRhsArity</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><span class="hs-identifier">_</span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span>
</span><span id="line-97"></span><span>
</span><span id="line-98"></span><span>
</span><span id="line-99"></span><span class="hs-comment">---------------</span><span>
</span><span id="line-100"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#exprArity"><span class="hs-identifier hs-type">exprArity</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#Arity"><span class="hs-identifier hs-type">Arity</span></a></span><span>
</span><span id="line-101"></span><span class="hs-comment">-- ^ An approximate, fast, version of 'exprEtaExpandArity'</span><span>
</span><span id="line-102"></span><span id="exprArity"><span class="annot"><span class="annottext">exprArity :: CoreExpr -&gt; JoinArity
</span><a href="GHC.Core.Opt.Arity.html#exprArity"><span class="hs-identifier hs-var hs-var">exprArity</span></a></span></span><span> </span><span id="local-6989586621680868083"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868083"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; JoinArity
</span><a href="#local-6989586621680868082"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868083"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-103"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-104"></span><span>    </span><span id="local-6989586621680868082"><span class="annot"><span class="annottext">go :: CoreExpr -&gt; JoinArity
</span><a href="#local-6989586621680868082"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621680868074"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680868074"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span>                     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; JoinArity
</span><a href="GHC.Types.Id.html#idArity"><span class="hs-identifier hs-var">idArity</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680868074"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-105"></span><span>    </span><span class="annot"><a href="#local-6989586621680868082"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-type">Lam</span></a></span><span> </span><span id="local-6989586621680868072"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680868072"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621680868071"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868071"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680868072"><span class="hs-identifier hs-var">x</span></a></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; JoinArity
</span><a href="#local-6989586621680868082"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868071"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; JoinArity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">1</span></span><span>
</span><span id="line-106"></span><span>                 </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; JoinArity
</span><a href="#local-6989586621680868082"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868071"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-107"></span><span>    </span><span class="annot"><a href="#local-6989586621680868082"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-type">Tick</span></a></span><span> </span><span id="local-6989586621680868070"><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680868070"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span id="local-6989586621680868069"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868069"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tickish Id -&gt; Bool
forall id. Tickish id -&gt; Bool
</span><a href="GHC.Core.html#tickishIsCode"><span class="hs-identifier hs-var">tickishIsCode</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680868070"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; JoinArity
</span><a href="#local-6989586621680868082"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868069"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-108"></span><span>    </span><span class="annot"><a href="#local-6989586621680868082"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-type">Cast</span></a></span><span> </span><span id="local-6989586621680868068"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868068"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span id="local-6989586621680868067"><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680868067"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>                 </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; Type -&gt; JoinArity
</span><a href="#local-6989586621680868066"><span class="hs-identifier hs-var">trim_arity</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; JoinArity
</span><a href="#local-6989586621680868082"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868068"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoercionR -&gt; Type
</span><a href="GHC.Core.Coercion.html#coercionRKind"><span class="hs-identifier hs-var">coercionRKind</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680868067"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-109"></span><span>                                        </span><span class="hs-comment">-- Note [exprArity invariant]</span><span>
</span><span id="line-110"></span><span>    </span><span class="annot"><a href="#local-6989586621680868082"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#App"><span class="hs-identifier hs-type">App</span></a></span><span> </span><span id="local-6989586621680868063"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868063"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; JoinArity
</span><a href="#local-6989586621680868082"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868063"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-111"></span><span>    </span><span class="annot"><a href="#local-6989586621680868082"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#App"><span class="hs-identifier hs-type">App</span></a></span><span> </span><span id="local-6989586621680868061"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868061"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621680868060"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868060"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Bool
</span><a href="GHC.Core.Utils.html#exprIsTrivial"><span class="hs-identifier hs-var">exprIsTrivial</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868060"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; JoinArity
</span><a href="#local-6989586621680868082"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868061"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; JoinArity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; JoinArity
forall a. Ord a =&gt; a -&gt; a -&gt; a
</span><span class="hs-operator hs-var">`max`</span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span>
</span><span id="line-112"></span><span>        </span><span class="hs-comment">-- See Note [exprArity for applications]</span><span>
</span><span id="line-113"></span><span>        </span><span class="hs-comment">-- NB: coercions count as a value argument</span><span>
</span><span id="line-114"></span><span>
</span><span id="line-115"></span><span>    </span><span class="annot"><a href="#local-6989586621680868082"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><span class="hs-identifier">_</span></span><span>                           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span>
</span><span id="line-116"></span><span>
</span><span id="line-117"></span><span>    </span><span class="annot"><a href="#local-6989586621680868066"><span class="hs-identifier hs-type">trim_arity</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#Arity"><span class="hs-identifier hs-type">Arity</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#Arity"><span class="hs-identifier hs-type">Arity</span></a></span><span>
</span><span id="line-118"></span><span>    </span><span id="local-6989586621680868066"><span class="annot"><span class="annottext">trim_arity :: JoinArity -&gt; Type -&gt; JoinArity
</span><a href="#local-6989586621680868066"><span class="hs-identifier hs-var hs-var">trim_arity</span></a></span></span><span> </span><span id="local-6989586621680868057"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680868057"><span class="hs-identifier hs-var">arity</span></a></span></span><span> </span><span id="local-6989586621680868056"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680868056"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680868057"><span class="hs-identifier hs-var">arity</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; JoinArity
forall a. Ord a =&gt; a -&gt; a -&gt; a
</span><span class="hs-operator hs-var">`min`</span></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; JoinArity
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; JoinArity
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; [OneShotInfo]
</span><a href="GHC.Core.Opt.Arity.html#typeArity"><span class="hs-identifier hs-var">typeArity</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680868056"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-119"></span><span>
</span><span id="line-120"></span><span class="hs-comment">---------------</span><span>
</span><span id="line-121"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#typeArity"><span class="hs-identifier hs-type">typeArity</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Basic.html#OneShotInfo"><span class="hs-identifier hs-type">OneShotInfo</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-122"></span><span class="hs-comment">-- How many value arrows are visible in the type?</span><span>
</span><span id="line-123"></span><span class="hs-comment">-- We look through foralls, and newtypes</span><span>
</span><span id="line-124"></span><span class="hs-comment">-- See Note [exprArity invariant]</span><span>
</span><span id="line-125"></span><span id="typeArity"><span class="annot"><span class="annottext">typeArity :: Type -&gt; [OneShotInfo]
</span><a href="GHC.Core.Opt.Arity.html#typeArity"><span class="hs-identifier hs-var hs-var">typeArity</span></a></span></span><span> </span><span id="local-6989586621680868053"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680868053"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-126"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RecTcChecker -&gt; Type -&gt; [OneShotInfo]
</span><a href="#local-6989586621680868052"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="GHC.Core.TyCon.html#initRecTc"><span class="hs-identifier hs-var">initRecTc</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680868053"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-127"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-128"></span><span>    </span><span id="local-6989586621680868052"><span class="annot"><span class="annottext">go :: RecTcChecker -&gt; Type -&gt; [OneShotInfo]
</span><a href="#local-6989586621680868052"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621680868050"><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621680868050"><span class="hs-identifier hs-var">rec_nts</span></a></span></span><span> </span><span id="local-6989586621680868049"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680868049"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-129"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680868048"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680868048"><span class="hs-identifier hs-var">ty'</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (Id, Type)
</span><a href="GHC.Core.Type.html#splitForAllTy_maybe"><span class="hs-identifier hs-var">splitForAllTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680868049"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-130"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RecTcChecker -&gt; Type -&gt; [OneShotInfo]
</span><a href="#local-6989586621680868052"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621680868050"><span class="hs-identifier hs-var">rec_nts</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680868048"><span class="hs-identifier hs-var">ty'</span></a></span><span>
</span><span id="line-131"></span><span>
</span><span id="line-132"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621680868046"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680868046"><span class="hs-identifier hs-var">arg</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680868045"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680868045"><span class="hs-identifier hs-var">res</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (Type, Type, Type)
</span><a href="GHC.Core.Type.html#splitFunTy_maybe"><span class="hs-identifier hs-var">splitFunTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680868049"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-133"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; OneShotInfo
</span><a href="GHC.Types.Id.html#typeOneShot"><span class="hs-identifier hs-var">typeOneShot</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680868046"><span class="hs-identifier hs-var">arg</span></a></span><span> </span><span class="annot"><span class="annottext">OneShotInfo -&gt; [OneShotInfo] -&gt; [OneShotInfo]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">RecTcChecker -&gt; Type -&gt; [OneShotInfo]
</span><a href="#local-6989586621680868052"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621680868050"><span class="hs-identifier hs-var">rec_nts</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680868045"><span class="hs-identifier hs-var">res</span></a></span><span>
</span><span id="line-134"></span><span>
</span><span id="line-135"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680868042"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680868042"><span class="hs-identifier hs-var">tc</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680868041"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680868041"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Maybe (TyCon, [Type])
Type -&gt; Maybe (TyCon, [Type])
</span><a href="GHC.Core.Type.html#splitTyConApp_maybe"><span class="hs-identifier hs-var">splitTyConApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680868049"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-136"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680868039"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680868039"><span class="hs-identifier hs-var">ty'</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [Type] -&gt; Maybe (Type, CoercionR)
</span><a href="GHC.Core.Coercion.html#instNewTyCon_maybe"><span class="hs-identifier hs-var">instNewTyCon_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680868042"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680868041"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-137"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680868037"><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621680868037"><span class="hs-identifier hs-var">rec_nts'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RecTcChecker -&gt; TyCon -&gt; Maybe RecTcChecker
</span><a href="GHC.Core.TyCon.html#checkRecTc"><span class="hs-identifier hs-var">checkRecTc</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621680868050"><span class="hs-identifier hs-var">rec_nts</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621680868042"><span class="hs-identifier hs-var">tc</span></a></span><span>  </span><span class="hs-comment">-- See Note [Expanding newtypes]</span><span>
</span><span id="line-138"></span><span>                                                </span><span class="hs-comment">-- in GHC.Core.TyCon</span><span>
</span><span id="line-139"></span><span class="hs-comment">--   , not (isClassTyCon tc)    -- Do not eta-expand through newtype classes</span><span>
</span><span id="line-140"></span><span class="hs-comment">--                              -- See Note [Newtype classes and eta expansion]</span><span>
</span><span id="line-141"></span><span class="hs-comment">--                              (no longer required)</span><span>
</span><span id="line-142"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">RecTcChecker -&gt; Type -&gt; [OneShotInfo]
</span><a href="#local-6989586621680868052"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621680868037"><span class="hs-identifier hs-var">rec_nts'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680868039"><span class="hs-identifier hs-var">ty'</span></a></span><span>
</span><span id="line-143"></span><span>        </span><span class="hs-comment">-- Important to look through non-recursive newtypes, so that, eg</span><span>
</span><span id="line-144"></span><span>        </span><span class="hs-comment">--      (f x)   where f has arity 2, f :: Int -&gt; IO ()</span><span>
</span><span id="line-145"></span><span>        </span><span class="hs-comment">-- Here we want to get arity 1 for the result!</span><span>
</span><span id="line-146"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-147"></span><span>        </span><span class="hs-comment">-- AND through a layer of recursive newtypes</span><span>
</span><span id="line-148"></span><span>        </span><span class="hs-comment">-- e.g. newtype Stream m a b = Stream (m (Either b (a, Stream m a b)))</span><span>
</span><span id="line-149"></span><span>
</span><span id="line-150"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-151"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-152"></span><span>
</span><span id="line-153"></span><span class="hs-comment">---------------</span><span>
</span><span id="line-154"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#exprBotStrictness_maybe"><span class="hs-identifier hs-type">exprBotStrictness_maybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Basic.html#Arity"><span class="hs-identifier hs-type">Arity</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Demand.html#StrictSig"><span class="hs-identifier hs-type">StrictSig</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-155"></span><span class="hs-comment">-- A cheap and cheerful function that identifies bottoming functions</span><span>
</span><span id="line-156"></span><span class="hs-comment">-- and gives them a suitable strictness signatures.  It's used during</span><span>
</span><span id="line-157"></span><span class="hs-comment">-- float-out</span><span>
</span><span id="line-158"></span><span id="exprBotStrictness_maybe"><span class="annot"><span class="annottext">exprBotStrictness_maybe :: CoreExpr -&gt; Maybe (JoinArity, StrictSig)
</span><a href="GHC.Core.Opt.Arity.html#exprBotStrictness_maybe"><span class="hs-identifier hs-var hs-var">exprBotStrictness_maybe</span></a></span></span><span> </span><span id="local-6989586621680868036"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868036"><span class="hs-identifier hs-var">e</span></a></span></span><span>
</span><span id="line-159"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ArityType -&gt; Maybe JoinArity
</span><a href="GHC.Core.Opt.Arity.html#getBotArity"><span class="hs-identifier hs-var">getBotArity</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ArityEnv -&gt; CoreExpr -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680868033"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680868036"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-160"></span><span>        </span><span class="annot"><span class="annottext">Maybe JoinArity
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe (JoinArity, StrictSig)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-161"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680868032"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680868032"><span class="hs-identifier hs-var">ar</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(JoinArity, StrictSig) -&gt; Maybe (JoinArity, StrictSig)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680868032"><span class="hs-identifier hs-var">ar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; StrictSig
</span><a href="#local-6989586621680868031"><span class="hs-identifier hs-var">sig</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680868032"><span class="hs-identifier hs-var">ar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-162"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-163"></span><span>    </span><span id="local-6989586621680868033"><span class="annot"><span class="annottext">env :: ArityEnv
</span><a href="#local-6989586621680868033"><span class="hs-identifier hs-var hs-var">env</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AE :: CheapFun -&gt; Bool -&gt; IdSet -&gt; ArityEnv
</span><a href="GHC.Core.Opt.Arity.html#AE"><span class="hs-identifier hs-type">AE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ae_ped_bot :: Bool
</span><a href="GHC.Core.Opt.Arity.html#ae_ped_bot"><span class="hs-identifier hs-var">ae_ped_bot</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-164"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ae_cheap_fn :: CheapFun
</span><a href="GHC.Core.Opt.Arity.html#ae_cheap_fn"><span class="hs-identifier hs-var">ae_cheap_fn</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-glyph">\</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Maybe Type
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-165"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ae_joins :: IdSet
</span><a href="GHC.Core.Opt.Arity.html#ae_joins"><span class="hs-identifier hs-var">ae_joins</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-166"></span><span>    </span><span id="local-6989586621680868031"><span class="annot"><span class="annottext">sig :: JoinArity -&gt; StrictSig
</span><a href="#local-6989586621680868031"><span class="hs-identifier hs-var hs-var">sig</span></a></span></span><span> </span><span id="local-6989586621680868025"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680868025"><span class="hs-identifier hs-var">ar</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Demand] -&gt; Divergence -&gt; StrictSig
</span><a href="GHC.Types.Demand.html#mkClosedStrictSig"><span class="hs-identifier hs-var">mkClosedStrictSig</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity -&gt; Demand -&gt; [Demand]
forall a. JoinArity -&gt; a -&gt; [a]
</span><a href="../../base/src/GHC.List.html#replicate"><span class="hs-identifier hs-var">replicate</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680868025"><span class="hs-identifier hs-var">ar</span></a></span><span> </span><span class="annot"><span class="annottext">Demand
</span><a href="GHC.Types.Demand.html#topDmd"><span class="hs-identifier hs-var">topDmd</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Divergence
</span><a href="GHC.Types.Demand.html#botDiv"><span class="hs-identifier hs-var">botDiv</span></a></span><span>
</span><span id="line-167"></span><span>
</span><span id="line-168"></span><span class="hs-comment">{-
Note [exprArity invariant]
~~~~~~~~~~~~~~~~~~~~~~~~~~
exprArity has the following invariants:

  (1) If typeArity (exprType e) = n,
      then manifestArity (etaExpand e n) = n

      That is, etaExpand can always expand as much as typeArity says
      So the case analysis in etaExpand and in typeArity must match

  (2) exprArity e &lt;= typeArity (exprType e)

  (3) Hence if (exprArity e) = n, then manifestArity (etaExpand e n) = n

      That is, if exprArity says &quot;the arity is n&quot; then etaExpand really
      can get &quot;n&quot; manifest lambdas to the top.

Why is this important?  Because
  - In GHC.Iface.Tidy we use exprArity to fix the *final arity* of
    each top-level Id, and in
  - In CorePrep we use etaExpand on each rhs, so that the visible lambdas
    actually match that arity, which in turn means
    that the StgRhs has the right number of lambdas

An alternative would be to do the eta-expansion in GHC.Iface.Tidy, at least
for top-level bindings, in which case we would not need the trim_arity
in exprArity.  That is a less local change, so I'm going to leave it for today!

Note [Newtype classes and eta expansion]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    NB: this nasty special case is no longer required, because
    for newtype classes we don't use the class-op rule mechanism
    at all.  See Note [Single-method classes] in GHC.Tc.TyCl.Instance. SLPJ May 2013

-------- Old out of date comments, just for interest -----------
We have to be careful when eta-expanding through newtypes.  In general
it's a good idea, but annoyingly it interacts badly with the class-op
rule mechanism.  Consider

   class C a where { op :: a -&gt; a }
   instance C b =&gt; C [b] where
     op x = ...

These translate to

   co :: forall a. (a-&gt;a) ~ C a

   $copList :: C b -&gt; [b] -&gt; [b]
   $copList d x = ...

   $dfList :: C b -&gt; C [b]
   {-# DFunUnfolding = [$copList] #-}
   $dfList d = $copList d |&gt; co@[b]

Now suppose we have:

   dCInt :: C Int

   blah :: [Int] -&gt; [Int]
   blah = op ($dfList dCInt)

Now we want the built-in op/$dfList rule will fire to give
   blah = $copList dCInt

But with eta-expansion 'blah' might (and in #3772, which is
slightly more complicated, does) turn into

   blah = op (\eta. ($dfList dCInt |&gt; sym co) eta)

and now it is *much* harder for the op/$dfList rule to fire, because
exprIsConApp_maybe won't hold of the argument to op.  I considered
trying to *make* it hold, but it's tricky and I gave up.

The test simplCore/should_compile/T3722 is an excellent example.
-------- End of old out of date comments, just for interest -----------


Note [exprArity for applications]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When we come to an application we check that the arg is trivial.
   eg  f (fac x) does not have arity 2,
                 even if f has arity 3!

* We require that is trivial rather merely cheap.  Suppose f has arity 2.
  Then    f (Just y)
  has arity 0, because if we gave it arity 1 and then inlined f we'd get
          let v = Just y in \w. &lt;f-body&gt;
  which has arity 0.  And we try to maintain the invariant that we don't
  have arity decreases.

*  The `max 0` is important!  (\x y -&gt; f x) has arity 2, even if f is
   unknown, hence arity 0


************************************************************************
*                                                                      *
           Computing the &quot;arity&quot; of an expression
*                                                                      *
************************************************************************

Note [Definition of arity]
~~~~~~~~~~~~~~~~~~~~~~~~~~
The &quot;arity&quot; of an expression 'e' is n if
   applying 'e' to *fewer* than n *value* arguments
   converges rapidly

Or, to put it another way

   there is no work lost in duplicating the partial
   application (e x1 .. x(n-1))

In the divergent case, no work is lost by duplicating because if the thing
is evaluated once, that's the end of the program.

Or, to put it another way, in any context C

   C[ (\x1 .. xn. e x1 .. xn) ]
         is as efficient as
   C[ e ]

It's all a bit more subtle than it looks:

Note [One-shot lambdas]
~~~~~~~~~~~~~~~~~~~~~~~
Consider one-shot lambdas
                let x = expensive in \y z -&gt; E
We want this to have arity 1 if the \y-abstraction is a 1-shot lambda.

Note [Dealing with bottom]
~~~~~~~~~~~~~~~~~~~~~~~~~~
A Big Deal with computing arities is expressions like

   f = \x -&gt; case x of
               True  -&gt; \s -&gt; e1
               False -&gt; \s -&gt; e2

This happens all the time when f :: Bool -&gt; IO ()
In this case we do eta-expand, in order to get that \s to the
top, and give f arity 2.

This isn't really right in the presence of seq.  Consider
        (f bot) `seq` 1

This should diverge!  But if we eta-expand, it won't.  We ignore this
&quot;problem&quot; (unless -fpedantic-bottoms is on), because being scrupulous
would lose an important transformation for many programs. (See
#5587 for an example.)

Consider also
        f = \x -&gt; error &quot;foo&quot;
Here, arity 1 is fine.  But if it is
        f = \x -&gt; case x of
                        True  -&gt; error &quot;foo&quot;
                        False -&gt; \y -&gt; x+y
then we want to get arity 2.  Technically, this isn't quite right, because
        (f True) `seq` 1
should diverge, but it'll converge if we eta-expand f.  Nevertheless, we
do so; it improves some programs significantly, and increasing convergence
isn't a bad thing.  Hence the ABot/ATop in ArityType.

So these two transformations aren't always the Right Thing, and we
have several tickets reporting unexpected behaviour resulting from
this transformation.  So we try to limit it as much as possible:

 (1) Do NOT move a lambda outside a known-bottom case expression
       case undefined of { (a,b) -&gt; \y -&gt; e }
     This showed up in #5557

 (2) Do NOT move a lambda outside a case if all the branches of
     the case are known to return bottom.
        case x of { (a,b) -&gt; \y -&gt; error &quot;urk&quot; }
     This case is less important, but the idea is that if the fn is
     going to diverge eventually anyway then getting the best arity
     isn't an issue, so we might as well play safe

 (3) Do NOT move a lambda outside a case unless
     (a) The scrutinee is ok-for-speculation, or
     (b) more liberally: the scrutinee is cheap (e.g. a variable), and
         -fpedantic-bottoms is not enforced (see #2915 for an example)

Of course both (1) and (2) are readily defeated by disguising the bottoms.

4. Note [Newtype arity]
~~~~~~~~~~~~~~~~~~~~~~~~
Non-recursive newtypes are transparent, and should not get in the way.
We do (currently) eta-expand recursive newtypes too.  So if we have, say

        newtype T = MkT ([T] -&gt; Int)

Suppose we have
        e = coerce T f
where f has arity 1.  Then: etaExpandArity e = 1;
that is, etaExpandArity looks through the coerce.

When we eta-expand e to arity 1: eta_expand 1 e T
we want to get:                  coerce T (\x::[T] -&gt; (coerce ([T]-&gt;Int) e) x)

  HOWEVER, note that if you use coerce bogusly you can ge
        coerce Int negate
  And since negate has arity 2, you might try to eta expand.  But you can't
  decompose Int to a function type.   Hence the final case in eta_expand.

Note [The state-transformer hack]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose we have
        f = e
where e has arity n.  Then, if we know from the context that f has
a usage type like
        t1 -&gt; ... -&gt; tn -1-&gt; t(n+1) -1-&gt; ... -1-&gt; tm -&gt; ...
then we can expand the arity to m.  This usage type says that
any application (x e1 .. en) will be applied to uniquely to (m-n) more args
Consider f = \x. let y = &lt;expensive&gt;
                 in case x of
                      True  -&gt; foo
                      False -&gt; \(s:RealWorld) -&gt; e
where foo has arity 1.  Then we want the state hack to
apply to foo too, so we can eta expand the case.

Then we expect that if f is applied to one arg, it'll be applied to two
(that's the hack -- we don't really know, and sometimes it's false)
See also Id.isOneShotBndr.

Note [State hack and bottoming functions]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It's a terrible idea to use the state hack on a bottoming function.
Here's what happens (#2861):

  f :: String -&gt; IO T
  f = \p. error &quot;...&quot;

Eta-expand, using the state hack:

  f = \p. (\s. ((error &quot;...&quot;) |&gt; g1) s) |&gt; g2
  g1 :: IO T ~ (S -&gt; (S,T))
  g2 :: (S -&gt; (S,T)) ~ IO T

Extrude the g2

  f' = \p. \s. ((error &quot;...&quot;) |&gt; g1) s
  f = f' |&gt; (String -&gt; g2)

Discard args for bottomming function

  f' = \p. \s. ((error &quot;...&quot;) |&gt; g1 |&gt; g3
  g3 :: (S -&gt; (S,T)) ~ (S,T)

Extrude g1.g3

  f'' = \p. \s. (error &quot;...&quot;)
  f' = f'' |&gt; (String -&gt; S -&gt; g1.g3)

And now we can repeat the whole loop.  Aargh!  The bug is in applying the
state hack to a function which then swallows the argument.

This arose in another guise in #3959.  Here we had

     catch# (throw exn &gt;&gt; return ())

Note that (throw :: forall a e. Exn e =&gt; e -&gt; a) is called with [a = IO ()].
After inlining (&gt;&gt;) we get

     catch# (\_. throw {IO ()} exn)

We must *not* eta-expand to

     catch# (\_ _. throw {...} exn)

because 'catch#' expects to get a (# _,_ #) after applying its argument to
a State#, not another function!

In short, we use the state hack to allow us to push let inside a lambda,
but not to introduce a new lambda.


Note [ArityType]
~~~~~~~~~~~~~~~~
ArityType is the result of a compositional analysis on expressions,
from which we can decide the real arity of the expression (extracted
with function exprEtaExpandArity).

Here is what the fields mean. If an arbitrary expression 'f' has
ArityType 'at', then

 * If at = ABot n, then (f x1..xn) definitely diverges. Partial
   applications to fewer than n args may *or may not* diverge.

   We allow ourselves to eta-expand bottoming functions, even
   if doing so may lose some `seq` sharing,
       let x = &lt;expensive&gt; in \y. error (g x y)
       ==&gt; \y. let x = &lt;expensive&gt; in error (g x y)

 * If at = ATop as, and n=length as,
   then expanding 'f' to (\x1..xn. f x1 .. xn) loses no sharing,
   assuming the calls of f respect the one-shot-ness of
   its definition.

   NB 'f' is an arbitrary expression, eg (f = g e1 e2).  This 'f'
   can have ArityType as ATop, with length as &gt; 0, only if e1 e2 are
   themselves.

 * In both cases, f, (f x1), ... (f x1 ... f(n-1)) are definitely
   really functions, or bottom, but *not* casts from a data type, in
   at least one case branch.  (If it's a function in one case branch but
   an unsafe cast from a data type in another, the program is bogus.)
   So eta expansion is dynamically ok; see Note [State hack and
   bottoming functions], the part about catch#

Example:
      f = \x\y. let v = &lt;expensive&gt; in
          \s(one-shot) \t(one-shot). blah
      'f' has ArityType [ManyShot,ManyShot,OneShot,OneShot]
      The one-shot-ness means we can, in effect, push that
      'let' inside the \st.


Suppose f = \xy. x+y
Then  f             :: AT [False,False] ATop
      f v           :: AT [False]       ATop
      f &lt;expensive&gt; :: AT []            ATop

-------------------- Main arity code ----------------------------
-}</span><span>
</span><span id="line-491"></span><span>
</span><span id="line-492"></span><span>
</span><span id="line-493"></span><span class="hs-keyword">data</span><span> </span><span id="ArityType"><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-var">ArityType</span></a></span></span><span>   </span><span class="hs-comment">-- See Note [ArityType]</span><span>
</span><span id="line-494"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="ATop"><span class="annot"><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-var">ATop</span></a></span></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Basic.html#OneShotInfo"><span class="hs-identifier hs-type">OneShotInfo</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-495"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="ABot"><span class="annot"><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-var">ABot</span></a></span></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#Arity"><span class="hs-identifier hs-type">Arity</span></a></span><span>
</span><span id="line-496"></span><span>  </span><span class="hs-keyword">deriving</span><span class="hs-special">(</span><span> </span><span id="local-6989586621680868011"><span id="local-6989586621680868017"><span class="annot"><span class="annottext">ArityType -&gt; ArityType -&gt; Bool
(ArityType -&gt; ArityType -&gt; Bool)
-&gt; (ArityType -&gt; ArityType -&gt; Bool) -&gt; Eq ArityType
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: ArityType -&gt; ArityType -&gt; Bool
$c/= :: ArityType -&gt; ArityType -&gt; Bool
== :: ArityType -&gt; ArityType -&gt; Bool
$c== :: ArityType -&gt; ArityType -&gt; Bool
</span><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></span></span></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-497"></span><span>     </span><span class="hs-comment">-- There is always an explicit lambda</span><span>
</span><span id="line-498"></span><span>     </span><span class="hs-comment">-- to justify the [OneShot], or the Arity</span><span>
</span><span id="line-499"></span><span>
</span><span id="line-500"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680868006"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-501"></span><span>  </span><span id="local-6989586621680868001"><span class="annot"><span class="annottext">ppr :: ArityType -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-type">ATop</span></a></span><span> </span><span id="local-6989586621680867999"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867999"><span class="hs-identifier hs-var">os</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ATop&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; JoinArity
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; JoinArity
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867999"><span class="hs-identifier hs-var">os</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-502"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-type">ABot</span></a></span><span> </span><span id="local-6989586621680867995"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867995"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ABot&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867995"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-503"></span><span>
</span><span id="line-504"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#arityTypeArity"><span class="hs-identifier hs-type">arityTypeArity</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#Arity"><span class="hs-identifier hs-type">Arity</span></a></span><span>
</span><span id="line-505"></span><span class="hs-comment">-- The number of value args for the arity type</span><span>
</span><span id="line-506"></span><span id="arityTypeArity"><span class="annot"><span class="annottext">arityTypeArity :: ArityType -&gt; JoinArity
</span><a href="GHC.Core.Opt.Arity.html#arityTypeArity"><span class="hs-identifier hs-var hs-var">arityTypeArity</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-type">ATop</span></a></span><span> </span><span id="local-6989586621680867994"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867994"><span class="hs-identifier hs-var">oss</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; JoinArity
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; JoinArity
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867994"><span class="hs-identifier hs-var">oss</span></a></span><span>
</span><span id="line-507"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#arityTypeArity"><span class="hs-identifier hs-var">arityTypeArity</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-type">ABot</span></a></span><span> </span><span id="local-6989586621680867993"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867993"><span class="hs-identifier hs-var">ar</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867993"><span class="hs-identifier hs-var">ar</span></a></span><span>
</span><span id="line-508"></span><span>
</span><span id="line-509"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#expandableArityType"><span class="hs-identifier hs-type">expandableArityType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-510"></span><span class="hs-comment">-- True &lt;=&gt; eta-expansion will add at least one lambda</span><span>
</span><span id="line-511"></span><span id="expandableArityType"><span class="annot"><span class="annottext">expandableArityType :: ArityType -&gt; Bool
</span><a href="GHC.Core.Opt.Arity.html#expandableArityType"><span class="hs-identifier hs-var hs-var">expandableArityType</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-type">ATop</span></a></span><span> </span><span id="local-6989586621680867992"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867992"><span class="hs-identifier hs-var">oss</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867992"><span class="hs-identifier hs-var">oss</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-512"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#expandableArityType"><span class="hs-identifier hs-var">expandableArityType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-type">ABot</span></a></span><span> </span><span id="local-6989586621680867990"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867990"><span class="hs-identifier hs-var">ar</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867990"><span class="hs-identifier hs-var">ar</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span>
</span><span id="line-513"></span><span>
</span><span id="line-514"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#isBotArityType"><span class="hs-identifier hs-type">isBotArityType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-515"></span><span id="isBotArityType"><span class="annot"><span class="annottext">isBotArityType :: ArityType -&gt; Bool
</span><a href="GHC.Core.Opt.Arity.html#isBotArityType"><span class="hs-identifier hs-var hs-var">isBotArityType</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-type">ABot</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-516"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#isBotArityType"><span class="hs-identifier hs-var">isBotArityType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-type">ATop</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-517"></span><span>
</span><span id="line-518"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#arityTypeOneShots"><span class="hs-identifier hs-type">arityTypeOneShots</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Basic.html#OneShotInfo"><span class="hs-identifier hs-type">OneShotInfo</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-519"></span><span id="arityTypeOneShots"><span class="annot"><span class="annottext">arityTypeOneShots :: ArityType -&gt; [OneShotInfo]
</span><a href="GHC.Core.Opt.Arity.html#arityTypeOneShots"><span class="hs-identifier hs-var hs-var">arityTypeOneShots</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-type">ATop</span></a></span><span> </span><span id="local-6989586621680867987"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867987"><span class="hs-identifier hs-var">oss</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867987"><span class="hs-identifier hs-var">oss</span></a></span><span>
</span><span id="line-520"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#arityTypeOneShots"><span class="hs-identifier hs-var">arityTypeOneShots</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-type">ABot</span></a></span><span> </span><span id="local-6989586621680867986"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867986"><span class="hs-identifier hs-var">ar</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; OneShotInfo -&gt; [OneShotInfo]
forall a. JoinArity -&gt; a -&gt; [a]
</span><a href="../../base/src/GHC.List.html#replicate"><span class="hs-identifier hs-var">replicate</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867986"><span class="hs-identifier hs-var">ar</span></a></span><span> </span><span class="annot"><span class="annottext">OneShotInfo
</span><a href="GHC.Types.Basic.html#OneShotLam"><span class="hs-identifier hs-var">OneShotLam</span></a></span><span>
</span><span id="line-521"></span><span>   </span><span class="hs-comment">-- If we are diveging or throwing an exception anyway</span><span>
</span><span id="line-522"></span><span>   </span><span class="hs-comment">-- it's fine to push redexes inside the lambdas</span><span>
</span><span id="line-523"></span><span>
</span><span id="line-524"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#botArityType"><span class="hs-identifier hs-type">botArityType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span>
</span><span id="line-525"></span><span id="botArityType"><span class="annot"><span class="annottext">botArityType :: ArityType
</span><a href="GHC.Core.Opt.Arity.html#botArityType"><span class="hs-identifier hs-var hs-var">botArityType</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-var">ABot</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span>   </span><span class="hs-comment">-- Unit for andArityType</span><span>
</span><span id="line-526"></span><span>
</span><span id="line-527"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#maxWithArity"><span class="hs-identifier hs-type">maxWithArity</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#Arity"><span class="hs-identifier hs-type">Arity</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span>
</span><span id="line-528"></span><span id="maxWithArity"><span class="annot"><span class="annottext">maxWithArity :: ArityType -&gt; JoinArity -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#maxWithArity"><span class="hs-identifier hs-var hs-var">maxWithArity</span></a></span></span><span> </span><span id="local-6989586621680867983"><span class="annot"><span class="annottext">at :: ArityType
</span><a href="#local-6989586621680867983"><span class="hs-identifier hs-var">at</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-type">ABot</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-identifier">_</span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ArityType
</span><a href="#local-6989586621680867983"><span class="hs-identifier hs-var">at</span></a></span><span>
</span><span id="line-529"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#maxWithArity"><span class="hs-identifier hs-var">maxWithArity</span></a></span><span> </span><span id="local-6989586621680867982"><span class="annot"><span class="annottext">at :: ArityType
</span><a href="#local-6989586621680867982"><span class="hs-identifier hs-var">at</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-type">ATop</span></a></span><span> </span><span id="local-6989586621680867981"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867981"><span class="hs-identifier hs-var">oss</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680867980"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867980"><span class="hs-identifier hs-var">ar</span></a></span></span><span>
</span><span id="line-530"></span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867981"><span class="hs-identifier hs-var">oss</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; JoinArity -&gt; Bool
forall a. [a] -&gt; JoinArity -&gt; Bool
</span><a href="GHC.Utils.Misc.html#lengthAtLeast"><span class="hs-operator hs-var">`lengthAtLeast`</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867980"><span class="hs-identifier hs-var">ar</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ArityType
</span><a href="#local-6989586621680867982"><span class="hs-identifier hs-var">at</span></a></span><span>
</span><span id="line-531"></span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-var">ATop</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity -&gt; [OneShotInfo] -&gt; [OneShotInfo]
forall a. JoinArity -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#take"><span class="hs-identifier hs-var">take</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867980"><span class="hs-identifier hs-var">ar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867981"><span class="hs-identifier hs-var">oss</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; [OneShotInfo] -&gt; [OneShotInfo]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">OneShotInfo -&gt; [OneShotInfo]
forall a. a -&gt; [a]
</span><a href="../../base/src/GHC.List.html#repeat"><span class="hs-identifier hs-var">repeat</span></a></span><span> </span><span class="annot"><span class="annottext">OneShotInfo
</span><a href="GHC.Types.Basic.html#NoOneShotInfo"><span class="hs-identifier hs-var">NoOneShotInfo</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-532"></span><span>
</span><span id="line-533"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#vanillaArityType"><span class="hs-identifier hs-type">vanillaArityType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span>
</span><span id="line-534"></span><span id="vanillaArityType"><span class="annot"><span class="annottext">vanillaArityType :: ArityType
</span><a href="GHC.Core.Opt.Arity.html#vanillaArityType"><span class="hs-identifier hs-var hs-var">vanillaArityType</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-var">ATop</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>      </span><span class="hs-comment">-- Totally uninformative</span><span>
</span><span id="line-535"></span><span>
</span><span id="line-536"></span><span class="hs-comment">-- ^ The Arity returned is the number of value args the</span><span>
</span><span id="line-537"></span><span class="hs-comment">-- expression can be applied to without doing much work</span><span>
</span><span id="line-538"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#exprEtaExpandArity"><span class="hs-identifier hs-type">exprEtaExpandArity</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span>
</span><span id="line-539"></span><span class="hs-comment">-- exprEtaExpandArity is used when eta expanding</span><span>
</span><span id="line-540"></span><span class="hs-comment">--      e  ==&gt;  \xy -&gt; e x y</span><span>
</span><span id="line-541"></span><span id="exprEtaExpandArity"><span class="annot"><span class="annottext">exprEtaExpandArity :: DynFlags -&gt; CoreExpr -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#exprEtaExpandArity"><span class="hs-identifier hs-var hs-var">exprEtaExpandArity</span></a></span></span><span> </span><span id="local-6989586621680867975"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680867975"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621680867974"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867974"><span class="hs-identifier hs-var">e</span></a></span></span><span>
</span><span id="line-542"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ArityEnv -&gt; CoreExpr -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867973"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867974"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-543"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-544"></span><span>    </span><span id="local-6989586621680867973"><span class="annot"><span class="annottext">env :: ArityEnv
</span><a href="#local-6989586621680867973"><span class="hs-identifier hs-var hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AE :: CheapFun -&gt; Bool -&gt; IdSet -&gt; ArityEnv
</span><a href="GHC.Core.Opt.Arity.html#AE"><span class="hs-identifier hs-type">AE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ae_cheap_fn :: CheapFun
</span><a href="GHC.Core.Opt.Arity.html#ae_cheap_fn"><span class="hs-identifier hs-var">ae_cheap_fn</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; CheapAppFun -&gt; CheapFun
</span><a href="GHC.Core.Opt.Arity.html#mk_cheap_fn"><span class="hs-identifier hs-var">mk_cheap_fn</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680867975"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CheapAppFun
</span><a href="GHC.Core.Utils.html#isCheapApp"><span class="hs-identifier hs-var">isCheapApp</span></a></span><span>
</span><span id="line-545"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ae_ped_bot :: Bool
</span><a href="GHC.Core.Opt.Arity.html#ae_ped_bot"><span class="hs-identifier hs-var">ae_ped_bot</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">GeneralFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#gopt"><span class="hs-identifier hs-var">gopt</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_PedanticBottoms"><span class="hs-identifier hs-var">Opt_PedanticBottoms</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680867975"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-546"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ae_joins :: IdSet
</span><a href="GHC.Core.Opt.Arity.html#ae_joins"><span class="hs-identifier hs-var">ae_joins</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-547"></span><span>
</span><span id="line-548"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#getBotArity"><span class="hs-identifier hs-type">getBotArity</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#Arity"><span class="hs-identifier hs-type">Arity</span></a></span><span>
</span><span id="line-549"></span><span class="hs-comment">-- Arity of a divergent function</span><span>
</span><span id="line-550"></span><span id="getBotArity"><span class="annot"><span class="annottext">getBotArity :: ArityType -&gt; Maybe JoinArity
</span><a href="GHC.Core.Opt.Arity.html#getBotArity"><span class="hs-identifier hs-var hs-var">getBotArity</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-type">ABot</span></a></span><span> </span><span id="local-6989586621680867969"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867969"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; Maybe JoinArity
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867969"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-551"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#getBotArity"><span class="hs-identifier hs-var">getBotArity</span></a></span><span> </span><span class="annot"><span class="annottext">ArityType
</span><span class="hs-identifier">_</span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe JoinArity
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-552"></span><span>
</span><span id="line-553"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#mk_cheap_fn"><span class="hs-identifier hs-type">mk_cheap_fn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#CheapAppFun"><span class="hs-identifier hs-type">CheapAppFun</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#CheapFun"><span class="hs-identifier hs-type">CheapFun</span></a></span><span>
</span><span id="line-554"></span><span id="mk_cheap_fn"><span class="annot"><span class="annottext">mk_cheap_fn :: DynFlags -&gt; CheapAppFun -&gt; CheapFun
</span><a href="GHC.Core.Opt.Arity.html#mk_cheap_fn"><span class="hs-identifier hs-var hs-var">mk_cheap_fn</span></a></span></span><span> </span><span id="local-6989586621680867968"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680867968"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621680867967"><span class="annot"><span class="annottext">CheapAppFun
</span><a href="#local-6989586621680867967"><span class="hs-identifier hs-var">cheap_app</span></a></span></span><span>
</span><span id="line-555"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GeneralFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#gopt"><span class="hs-identifier hs-var">gopt</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_DictsCheap"><span class="hs-identifier hs-var">Opt_DictsCheap</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680867968"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-556"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621680867965"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867965"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="annot"><span class="annottext">Maybe Type
</span><span class="hs-identifier">_</span></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CheapAppFun -&gt; CoreExpr -&gt; Bool
</span><a href="GHC.Core.Utils.html#exprIsCheapX"><span class="hs-identifier hs-var">exprIsCheapX</span></a></span><span> </span><span class="annot"><span class="annottext">CheapAppFun
</span><a href="#local-6989586621680867967"><span class="hs-identifier hs-var">cheap_app</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867965"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-557"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-558"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621680867963"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867963"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span id="local-6989586621680867962"><span class="annot"><span class="annottext">Maybe Type
</span><a href="#local-6989586621680867962"><span class="hs-identifier hs-var">mb_ty</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CheapAppFun -&gt; CoreExpr -&gt; Bool
</span><a href="GHC.Core.Utils.html#exprIsCheapX"><span class="hs-identifier hs-var">exprIsCheapX</span></a></span><span> </span><span class="annot"><span class="annottext">CheapAppFun
</span><a href="#local-6989586621680867967"><span class="hs-identifier hs-var">cheap_app</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867963"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-559"></span><span>             </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe Type
</span><a href="#local-6989586621680867962"><span class="hs-identifier hs-var">mb_ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-560"></span><span>                  </span><span class="annot"><span class="annottext">Maybe Type
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-561"></span><span>                  </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680867960"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867960"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.Predicate.html#isDictTy"><span class="hs-identifier hs-var">isDictTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867960"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-562"></span><span>
</span><span id="line-563"></span><span>
</span><span id="line-564"></span><span class="hs-comment">----------------------</span><span>
</span><span id="line-565"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#findRhsArity"><span class="hs-identifier hs-type">findRhsArity</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#Arity"><span class="hs-identifier hs-type">Arity</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span>
</span><span id="line-566"></span><span class="hs-comment">-- This implements the fixpoint loop for arity analysis</span><span>
</span><span id="line-567"></span><span class="hs-comment">-- See Note [Arity analysis]</span><span>
</span><span id="line-568"></span><span class="hs-comment">-- If findRhsArity e = (n, is_bot) then</span><span>
</span><span id="line-569"></span><span class="hs-comment">--  (a) any application of e to &lt;n arguments will not do much work,</span><span>
</span><span id="line-570"></span><span class="hs-comment">--      so it is safe to expand e  ==&gt;  (\x1..xn. e x1 .. xn)</span><span>
</span><span id="line-571"></span><span class="hs-comment">--  (b) if is_bot=True, then e applied to n args is guaranteed bottom</span><span>
</span><span id="line-572"></span><span id="findRhsArity"><span class="annot"><span class="annottext">findRhsArity :: DynFlags -&gt; Id -&gt; CoreExpr -&gt; JoinArity -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#findRhsArity"><span class="hs-identifier hs-var hs-var">findRhsArity</span></a></span></span><span> </span><span id="local-6989586621680867959"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680867959"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621680867958"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867958"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680867957"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867957"><span class="hs-identifier hs-var">rhs</span></a></span></span><span> </span><span id="local-6989586621680867956"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867956"><span class="hs-identifier hs-var">old_arity</span></a></span></span><span>
</span><span id="line-573"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ArityType -&gt; ArityType
</span><a href="#local-6989586621680867955"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CheapAppFun -&gt; ArityType
</span><a href="#local-6989586621680867954"><span class="hs-identifier hs-var">get_arity</span></a></span><span> </span><span class="annot"><span class="annottext">CheapAppFun
</span><a href="#local-6989586621680867953"><span class="hs-identifier hs-var">init_cheap_app</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-574"></span><span>       </span><span class="hs-comment">-- We always call exprEtaExpandArity once, but usually</span><span>
</span><span id="line-575"></span><span>       </span><span class="hs-comment">-- that produces a result equal to old_arity, and then</span><span>
</span><span id="line-576"></span><span>       </span><span class="hs-comment">-- we stop right away (since arities should not decrease)</span><span>
</span><span id="line-577"></span><span>       </span><span class="hs-comment">-- Result: the common case is that there is just one iteration</span><span>
</span><span id="line-578"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-579"></span><span>    </span><span class="annot"><a href="#local-6989586621680867953"><span class="hs-identifier hs-type">init_cheap_app</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#CheapAppFun"><span class="hs-identifier hs-type">CheapAppFun</span></a></span><span>
</span><span id="line-580"></span><span>    </span><span id="local-6989586621680867953"><span class="annot"><span class="annottext">init_cheap_app :: CheapAppFun
</span><a href="#local-6989586621680867953"><span class="hs-identifier hs-var hs-var">init_cheap_app</span></a></span></span><span> </span><span id="local-6989586621680867952"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867952"><span class="hs-identifier hs-var">fn</span></a></span></span><span> </span><span id="local-6989586621680867951"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867951"><span class="hs-identifier hs-var">n_val_args</span></a></span></span><span>
</span><span id="line-581"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867952"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Id -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867958"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>   </span><span class="hs-comment">-- On the first pass, this binder gets infinite arity</span><span>
</span><span id="line-582"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CheapAppFun
</span><a href="GHC.Core.Utils.html#isCheapApp"><span class="hs-identifier hs-var">isCheapApp</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867952"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867951"><span class="hs-identifier hs-var">n_val_args</span></a></span><span>
</span><span id="line-583"></span><span>
</span><span id="line-584"></span><span>    </span><span class="annot"><a href="#local-6989586621680867955"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span>
</span><span id="line-585"></span><span>    </span><span id="local-6989586621680867955"><span class="annot"><span class="annottext">go :: ArityType -&gt; ArityType
</span><a href="#local-6989586621680867955"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621680867950"><span class="annot"><span class="annottext">ArityType
</span><a href="#local-6989586621680867950"><span class="hs-identifier hs-var">cur_atype</span></a></span></span><span>
</span><span id="line-586"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867949"><span class="hs-identifier hs-var">cur_arity</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;=</span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867956"><span class="hs-identifier hs-var">old_arity</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ArityType
</span><a href="#local-6989586621680867950"><span class="hs-identifier hs-var">cur_atype</span></a></span><span>
</span><span id="line-587"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">ArityType
</span><a href="#local-6989586621680867947"><span class="hs-identifier hs-var">new_atype</span></a></span><span> </span><span class="annot"><span class="annottext">ArityType -&gt; ArityType -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">ArityType
</span><a href="#local-6989586621680867950"><span class="hs-identifier hs-var">cur_atype</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ArityType
</span><a href="#local-6989586621680867950"><span class="hs-identifier hs-var">cur_atype</span></a></span><span>
</span><span id="line-588"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span class="hs-cpp">
#if defined(DEBUG)
</span><span>                    </span><span class="hs-identifier">pprTrace</span><span> </span><span class="hs-string">&quot;Exciting arity&quot;</span><span>
</span><span id="line-591"></span><span>                       </span><span class="hs-special">(</span><span class="hs-identifier">vcat</span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">bndr</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">cur_atype</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">new_atype</span><span>
</span><span id="line-592"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">rhs</span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span>                    </span><span class="annot"><span class="annottext">ArityType -&gt; ArityType
</span><a href="#local-6989586621680867955"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">ArityType
</span><a href="#local-6989586621680867947"><span class="hs-identifier hs-var">new_atype</span></a></span><span>
</span><span id="line-595"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-596"></span><span>        </span><span id="local-6989586621680867947"><span class="annot"><span class="annottext">new_atype :: ArityType
</span><a href="#local-6989586621680867947"><span class="hs-identifier hs-var hs-var">new_atype</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CheapAppFun -&gt; ArityType
</span><a href="#local-6989586621680867954"><span class="hs-identifier hs-var">get_arity</span></a></span><span> </span><span class="annot"><span class="annottext">CheapAppFun
</span><a href="#local-6989586621680867946"><span class="hs-identifier hs-var">cheap_app</span></a></span><span>
</span><span id="line-597"></span><span>
</span><span id="line-598"></span><span>        </span><span id="local-6989586621680867949"><span class="annot"><span class="annottext">cur_arity :: JoinArity
</span><a href="#local-6989586621680867949"><span class="hs-identifier hs-var hs-var">cur_arity</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ArityType -&gt; JoinArity
</span><a href="GHC.Core.Opt.Arity.html#arityTypeArity"><span class="hs-identifier hs-var">arityTypeArity</span></a></span><span> </span><span class="annot"><span class="annottext">ArityType
</span><a href="#local-6989586621680867950"><span class="hs-identifier hs-var">cur_atype</span></a></span><span>
</span><span id="line-599"></span><span>        </span><span class="annot"><a href="#local-6989586621680867946"><span class="hs-identifier hs-type">cheap_app</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#CheapAppFun"><span class="hs-identifier hs-type">CheapAppFun</span></a></span><span>
</span><span id="line-600"></span><span>        </span><span id="local-6989586621680867946"><span class="annot"><span class="annottext">cheap_app :: CheapAppFun
</span><a href="#local-6989586621680867946"><span class="hs-identifier hs-var hs-var">cheap_app</span></a></span></span><span> </span><span id="local-6989586621680867945"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867945"><span class="hs-identifier hs-var">fn</span></a></span></span><span> </span><span id="local-6989586621680867944"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867944"><span class="hs-identifier hs-var">n_val_args</span></a></span></span><span>
</span><span id="line-601"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867945"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Id -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867958"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867944"><span class="hs-identifier hs-var">n_val_args</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;</span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867949"><span class="hs-identifier hs-var">cur_arity</span></a></span><span>
</span><span id="line-602"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CheapAppFun
</span><a href="GHC.Core.Utils.html#isCheapApp"><span class="hs-identifier hs-var">isCheapApp</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867945"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867944"><span class="hs-identifier hs-var">n_val_args</span></a></span><span>
</span><span id="line-603"></span><span>
</span><span id="line-604"></span><span>    </span><span class="annot"><a href="#local-6989586621680867954"><span class="hs-identifier hs-type">get_arity</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Utils.html#CheapAppFun"><span class="hs-identifier hs-type">CheapAppFun</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span>
</span><span id="line-605"></span><span>    </span><span id="local-6989586621680867954"><span class="annot"><span class="annottext">get_arity :: CheapAppFun -&gt; ArityType
</span><a href="#local-6989586621680867954"><span class="hs-identifier hs-var hs-var">get_arity</span></a></span></span><span> </span><span id="local-6989586621680867942"><span class="annot"><span class="annottext">CheapAppFun
</span><a href="#local-6989586621680867942"><span class="hs-identifier hs-var">cheap_app</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ArityEnv -&gt; CoreExpr -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867941"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867957"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-606"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-607"></span><span>         </span><span id="local-6989586621680867941"><span class="annot"><span class="annottext">env :: ArityEnv
</span><a href="#local-6989586621680867941"><span class="hs-identifier hs-var hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AE :: CheapFun -&gt; Bool -&gt; IdSet -&gt; ArityEnv
</span><a href="GHC.Core.Opt.Arity.html#AE"><span class="hs-identifier hs-type">AE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ae_cheap_fn :: CheapFun
</span><a href="GHC.Core.Opt.Arity.html#ae_cheap_fn"><span class="hs-identifier hs-var">ae_cheap_fn</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; CheapAppFun -&gt; CheapFun
</span><a href="GHC.Core.Opt.Arity.html#mk_cheap_fn"><span class="hs-identifier hs-var">mk_cheap_fn</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680867959"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">CheapAppFun
</span><a href="#local-6989586621680867942"><span class="hs-identifier hs-var">cheap_app</span></a></span><span>
</span><span id="line-608"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ae_ped_bot :: Bool
</span><a href="GHC.Core.Opt.Arity.html#ae_ped_bot"><span class="hs-identifier hs-var">ae_ped_bot</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">GeneralFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#gopt"><span class="hs-identifier hs-var">gopt</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_PedanticBottoms"><span class="hs-identifier hs-var">Opt_PedanticBottoms</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621680867959"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-609"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ae_joins :: IdSet
</span><a href="GHC.Core.Opt.Arity.html#ae_joins"><span class="hs-identifier hs-var">ae_joins</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-610"></span><span>
</span><span id="line-611"></span><span class="hs-comment">{-
Note [Arity analysis]
~~~~~~~~~~~~~~~~~~~~~
The motivating example for arity analysis is this:

  f = \x. let g = f (x+1)
          in \y. ...g...

What arity does f have?  Really it should have arity 2, but a naive
look at the RHS won't see that.  You need a fixpoint analysis which
says it has arity &quot;infinity&quot; the first time round.

This example happens a lot; it first showed up in Andy Gill's thesis,
fifteen years ago!  It also shows up in the code for 'rnf' on lists
in #4138.

The analysis is easy to achieve because exprEtaExpandArity takes an
argument
     type CheapFun = CoreExpr -&gt; Maybe Type -&gt; Bool
used to decide if an expression is cheap enough to push inside a
lambda.  And exprIsCheapX in turn takes an argument
     type CheapAppFun = Id -&gt; Int -&gt; Bool
which tells when an application is cheap. This makes it easy to
write the analysis loop.

The analysis is cheap-and-cheerful because it doesn't deal with
mutual recursion.  But the self-recursive case is the important one.

Note [Eta expanding through dictionaries]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If the experimental -fdicts-cheap flag is on, we eta-expand through
dictionary bindings.  This improves arities. Thereby, it also
means that full laziness is less prone to floating out the
application of a function to its dictionary arguments, which
can thereby lose opportunities for fusion.  Example:
        foo :: Ord a =&gt; a -&gt; ...
     foo = /\a \(d:Ord a). let d' = ...d... in \(x:a). ....
        -- So foo has arity 1

     f = \x. foo dInt $ bar x

The (foo DInt) is floated out, and makes ineffective a RULE
     foo (bar x) = ...

One could go further and make exprIsCheap reply True to any
dictionary-typed expression, but that's more work.
-}</span><span>
</span><span id="line-658"></span><span>
</span><span id="line-659"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#arityLam"><span class="hs-identifier hs-type">arityLam</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span>
</span><span id="line-660"></span><span id="arityLam"><span class="annot"><span class="annottext">arityLam :: Id -&gt; ArityType -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#arityLam"><span class="hs-identifier hs-var hs-var">arityLam</span></a></span></span><span> </span><span id="local-6989586621680867939"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867939"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-type">ATop</span></a></span><span> </span><span id="local-6989586621680867938"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867938"><span class="hs-keyword hs-var">as</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-var">ATop</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; OneShotInfo
</span><a href="GHC.Types.Id.html#idStateHackOneShotInfo"><span class="hs-identifier hs-var">idStateHackOneShotInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867939"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">OneShotInfo -&gt; [OneShotInfo] -&gt; [OneShotInfo]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867938"><span class="hs-keyword hs-var">as</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-661"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#arityLam"><span class="hs-identifier hs-var">arityLam</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span>  </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-type">ABot</span></a></span><span> </span><span id="local-6989586621680867936"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867936"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-var">ABot</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867936"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; JoinArity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-662"></span><span>
</span><span id="line-663"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#floatIn"><span class="hs-identifier hs-type">floatIn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span>
</span><span id="line-664"></span><span class="hs-comment">-- We have something like (let x = E in b),</span><span>
</span><span id="line-665"></span><span class="hs-comment">-- where b has the given arity type.</span><span>
</span><span id="line-666"></span><span id="floatIn"><span class="annot"><span class="annottext">floatIn :: Bool -&gt; ArityType -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#floatIn"><span class="hs-identifier hs-var hs-var">floatIn</span></a></span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span>     </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-type">ABot</span></a></span><span> </span><span id="local-6989586621680867934"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867934"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-var">ABot</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867934"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-667"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#floatIn"><span class="hs-identifier hs-var">floatIn</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>  </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-type">ATop</span></a></span><span> </span><span id="local-6989586621680867933"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867933"><span class="hs-keyword hs-var">as</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-var">ATop</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867933"><span class="hs-keyword hs-var">as</span></a></span><span>
</span><span id="line-668"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#floatIn"><span class="hs-identifier hs-var">floatIn</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-type">ATop</span></a></span><span> </span><span id="local-6989586621680867932"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867932"><span class="hs-keyword hs-var">as</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-var">ATop</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(OneShotInfo -&gt; Bool) -&gt; [OneShotInfo] -&gt; [OneShotInfo]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#takeWhile"><span class="hs-identifier hs-var">takeWhile</span></a></span><span> </span><span class="annot"><span class="annottext">OneShotInfo -&gt; Bool
</span><a href="GHC.Types.Basic.html#isOneShotInfo"><span class="hs-identifier hs-var">isOneShotInfo</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867932"><span class="hs-keyword hs-var">as</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-669"></span><span>   </span><span class="hs-comment">-- If E is not cheap, keep arity only for one-shots</span><span>
</span><span id="line-670"></span><span>
</span><span id="line-671"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#arityApp"><span class="hs-identifier hs-type">arityApp</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span>
</span><span id="line-672"></span><span class="hs-comment">-- Processing (fun arg) where at is the ArityType of fun,</span><span>
</span><span id="line-673"></span><span class="hs-comment">-- Knock off an argument and behave like 'let'</span><span>
</span><span id="line-674"></span><span id="arityApp"><span class="annot"><span class="annottext">arityApp :: ArityType -&gt; Bool -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#arityApp"><span class="hs-identifier hs-var hs-var">arityApp</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-type">ABot</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span>      </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-var">ABot</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span>
</span><span id="line-675"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#arityApp"><span class="hs-identifier hs-var">arityApp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-type">ABot</span></a></span><span> </span><span id="local-6989586621680867928"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867928"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">)</span><span>      </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-var">ABot</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867928"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; JoinArity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-676"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#arityApp"><span class="hs-identifier hs-var">arityApp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-type">ATop</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>     </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-var">ATop</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-677"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#arityApp"><span class="hs-identifier hs-var">arityApp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-type">ATop</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OneShotInfo
</span><span class="hs-identifier">_</span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680867927"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867927"><span class="hs-keyword hs-var">as</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680867926"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680867926"><span class="hs-identifier hs-var">cheap</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; ArityType -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#floatIn"><span class="hs-identifier hs-var">floatIn</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680867926"><span class="hs-identifier hs-var">cheap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-var">ATop</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867927"><span class="hs-keyword hs-var">as</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-678"></span><span>
</span><span id="line-679"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#andArityType"><span class="hs-identifier hs-type">andArityType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span>   </span><span class="hs-comment">-- Used for branches of a 'case'</span><span>
</span><span id="line-680"></span><span class="hs-comment">-- This is least upper bound in the ArityType lattice</span><span>
</span><span id="line-681"></span><span id="andArityType"><span class="annot"><span class="annottext">andArityType :: ArityType -&gt; ArityType -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#andArityType"><span class="hs-identifier hs-var hs-var">andArityType</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-type">ABot</span></a></span><span> </span><span id="local-6989586621680867924"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867924"><span class="hs-identifier hs-var">n1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-type">ABot</span></a></span><span> </span><span id="local-6989586621680867923"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867923"><span class="hs-identifier hs-var">n2</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-var">ABot</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867924"><span class="hs-identifier hs-var">n1</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; JoinArity
forall a. Ord a =&gt; a -&gt; a -&gt; a
</span><span class="hs-operator hs-var">`max`</span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867923"><span class="hs-identifier hs-var">n2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- Note [ABot branches: use max]</span><span>
</span><span id="line-682"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#andArityType"><span class="hs-identifier hs-var">andArityType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-type">ATop</span></a></span><span> </span><span id="local-6989586621680867922"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867922"><span class="hs-keyword hs-var">as</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-type">ABot</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-var">ATop</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867922"><span class="hs-keyword hs-var">as</span></a></span><span>
</span><span id="line-683"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#andArityType"><span class="hs-identifier hs-var">andArityType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-type">ABot</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>   </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-type">ATop</span></a></span><span> </span><span id="local-6989586621680867921"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867921"><span class="hs-identifier hs-var">bs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-var">ATop</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867921"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-684"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#andArityType"><span class="hs-identifier hs-var">andArityType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-type">ATop</span></a></span><span> </span><span id="local-6989586621680867920"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867920"><span class="hs-keyword hs-var">as</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-type">ATop</span></a></span><span> </span><span id="local-6989586621680867919"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867919"><span class="hs-identifier hs-var">bs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-var">ATop</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867920"><span class="hs-keyword hs-var">as</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; [OneShotInfo] -&gt; [OneShotInfo]
</span><a href="#local-6989586621680867918"><span class="hs-operator hs-var">`combine`</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867919"><span class="hs-identifier hs-var">bs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-685"></span><span>  </span><span class="hs-keyword">where</span><span>      </span><span class="hs-comment">-- See Note [Combining case branches]</span><span>
</span><span id="line-686"></span><span>    </span><span id="local-6989586621680867918"><span class="annot"><span class="annottext">combine :: [OneShotInfo] -&gt; [OneShotInfo] -&gt; [OneShotInfo]
</span><a href="#local-6989586621680867918"><span class="hs-identifier hs-var hs-var">combine</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680867917"><span class="annot"><span class="annottext">OneShotInfo
</span><a href="#local-6989586621680867917"><span class="hs-identifier hs-var">a</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680867916"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867916"><span class="hs-keyword hs-var">as</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680867915"><span class="annot"><span class="annottext">OneShotInfo
</span><a href="#local-6989586621680867915"><span class="hs-identifier hs-var">b</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680867914"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867914"><span class="hs-identifier hs-var">bs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OneShotInfo
</span><a href="#local-6989586621680867917"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">OneShotInfo -&gt; OneShotInfo -&gt; OneShotInfo
</span><a href="GHC.Types.Basic.html#bestOneShot"><span class="hs-operator hs-var">`bestOneShot`</span></a></span><span> </span><span class="annot"><span class="annottext">OneShotInfo
</span><a href="#local-6989586621680867915"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">OneShotInfo -&gt; [OneShotInfo] -&gt; [OneShotInfo]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; [OneShotInfo] -&gt; [OneShotInfo]
</span><a href="#local-6989586621680867918"><span class="hs-identifier hs-var">combine</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867916"><span class="hs-keyword hs-var">as</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867914"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-687"></span><span>    </span><span class="annot"><a href="#local-6989586621680867918"><span class="hs-identifier hs-var">combine</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span id="local-6989586621680867912"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867912"><span class="hs-identifier hs-var">bs</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OneShotInfo -&gt; Bool) -&gt; [OneShotInfo] -&gt; [OneShotInfo]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#takeWhile"><span class="hs-identifier hs-var">takeWhile</span></a></span><span> </span><span class="annot"><span class="annottext">OneShotInfo -&gt; Bool
</span><a href="GHC.Types.Basic.html#isOneShotInfo"><span class="hs-identifier hs-var">isOneShotInfo</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867912"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-688"></span><span>    </span><span class="annot"><a href="#local-6989586621680867918"><span class="hs-identifier hs-var">combine</span></a></span><span> </span><span id="local-6989586621680867911"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867911"><span class="hs-keyword hs-var">as</span></a></span></span><span>     </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(OneShotInfo -&gt; Bool) -&gt; [OneShotInfo] -&gt; [OneShotInfo]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#takeWhile"><span class="hs-identifier hs-var">takeWhile</span></a></span><span> </span><span class="annot"><span class="annottext">OneShotInfo -&gt; Bool
</span><a href="GHC.Types.Basic.html#isOneShotInfo"><span class="hs-identifier hs-var">isOneShotInfo</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867911"><span class="hs-keyword hs-var">as</span></a></span><span>
</span><span id="line-689"></span><span>
</span><span id="line-690"></span><span class="hs-comment">{- Note [ABot branches: use max]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider   case x of
             True  -&gt; \x.  error &quot;urk&quot;
             False -&gt; \xy. error &quot;urk2&quot;

Remember: ABot n means &quot;if you apply to n args, it'll definitely diverge&quot;.
So we need (ABot 2) for the whole thing, the /max/ of the ABot arities.

Note [Combining case branches]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
  go = \x. let z = go e0
               go2 = \x. case x of
                           True  -&gt; z
                           False -&gt; \s(one-shot). e1
           in go2 x
We *really* want to eta-expand go and go2.
When combining the branches of the case we have
     ATop [] `andAT` ATop [OneShotLam]
and we want to get ATop [OneShotLam].  But if the inner
lambda wasn't one-shot we don't want to do this.
(We need a proper arity analysis to justify that.)

So we combine the best of the two branches, on the (slightly dodgy)
basis that if we know one branch is one-shot, then they all must be.

Note [Arity trimming]
~~~~~~~~~~~~~~~~~~~~~
Consider ((\x y. blah) |&gt; co), where co :: (Int-&gt;Int-&gt;Int) ~ (Int -&gt; F a) , and
F is some type family.

Because of Note [exprArity invariant], item (2), we must return with arity at
most 1, because typeArity (Int -&gt; F a) = 1.  So we have to trim the result of
calling arityType on (\x y. blah).  Failing to do so, and hence breaking the
exprArity invariant, led to #5441.

How to trim?  For ATop, it's easy.  But we must take great care with ABot.
Suppose the expression was (\x y. error &quot;urk&quot;), we'll get (ABot 2).  We
absolutely must not trim that to (ABot 1), because that claims that
((\x y. error &quot;urk&quot;) |&gt; co) diverges when given one argument, which it
absolutely does not. And Bad Things happen if we think something returns bottom
when it doesn't (#16066).

So, do not reduce the 'n' in (ABot n); rather, switch (conservatively) to ATop.

Historical note: long ago, we unconditionally switched to ATop when we
encountered a cast, but that is far too conservative: see #5475
-}</span><span>
</span><span id="line-739"></span><span>
</span><span id="line-740"></span><span class="hs-comment">---------------------------</span><span>
</span><span id="line-741"></span><span class="hs-keyword">type</span><span> </span><span id="CheapFun"><span class="annot"><a href="GHC.Core.Opt.Arity.html#CheapFun"><span class="hs-identifier hs-var">CheapFun</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-742"></span><span>        </span><span class="hs-comment">-- How to decide if an expression is cheap</span><span>
</span><span id="line-743"></span><span>        </span><span class="hs-comment">-- If the Maybe is Just, the type is the type</span><span>
</span><span id="line-744"></span><span>        </span><span class="hs-comment">-- of the expression; Nothing means &quot;don't know&quot;</span><span>
</span><span id="line-745"></span><span>
</span><span id="line-746"></span><span class="hs-keyword">data</span><span> </span><span id="ArityEnv"><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityEnv"><span class="hs-identifier hs-var">ArityEnv</span></a></span></span><span>
</span><span id="line-747"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="AE"><span class="annot"><a href="GHC.Core.Opt.Arity.html#AE"><span class="hs-identifier hs-var">AE</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="ae_cheap_fn"><span class="annot"><span class="annottext">ArityEnv -&gt; CheapFun
</span><a href="GHC.Core.Opt.Arity.html#ae_cheap_fn"><span class="hs-identifier hs-var hs-var">ae_cheap_fn</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#CheapFun"><span class="hs-identifier hs-type">CheapFun</span></a></span><span>
</span><span id="line-748"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="ae_ped_bot"><span class="annot"><span class="annottext">ArityEnv -&gt; Bool
</span><a href="GHC.Core.Opt.Arity.html#ae_ped_bot"><span class="hs-identifier hs-var hs-var">ae_ped_bot</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>       </span><span class="hs-comment">-- True &lt;=&gt; be pedantic about bottoms</span><span>
</span><span id="line-749"></span><span>       </span><span class="hs-special">,</span><span> </span><span id="ae_joins"><span class="annot"><span class="annottext">ArityEnv -&gt; IdSet
</span><a href="GHC.Core.Opt.Arity.html#ae_joins"><span class="hs-identifier hs-var hs-var">ae_joins</span></a></span></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#IdSet"><span class="hs-identifier hs-type">IdSet</span></a></span><span>      </span><span class="hs-comment">-- In-scope join points</span><span>
</span><span id="line-750"></span><span>                                   </span><span class="hs-comment">-- See Note [Eta-expansion and join points]</span><span>
</span><span id="line-751"></span><span>  </span><span class="hs-special">}</span><span>
</span><span id="line-752"></span><span>
</span><span id="line-753"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#extendJoinEnv"><span class="hs-identifier hs-type">extendJoinEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityEnv"><span class="hs-identifier hs-type">ArityEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#JoinId"><span class="hs-identifier hs-type">JoinId</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityEnv"><span class="hs-identifier hs-type">ArityEnv</span></a></span><span>
</span><span id="line-754"></span><span id="extendJoinEnv"><span class="annot"><span class="annottext">extendJoinEnv :: ArityEnv -&gt; [Id] -&gt; ArityEnv
</span><a href="GHC.Core.Opt.Arity.html#extendJoinEnv"><span class="hs-identifier hs-var hs-var">extendJoinEnv</span></a></span></span><span> </span><span id="local-6989586621680867908"><span class="annot"><span class="annottext">env :: ArityEnv
</span><a href="#local-6989586621680867908"><span class="hs-identifier hs-var">env</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#AE"><span class="hs-identifier hs-type">AE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ae_joins :: ArityEnv -&gt; IdSet
</span><a href="GHC.Core.Opt.Arity.html#ae_joins"><span class="hs-identifier hs-var">ae_joins</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680867907"><span class="annot"><span class="annottext">IdSet
</span><a href="#local-6989586621680867907"><span class="hs-identifier hs-var">joins</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621680867906"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867906"><span class="hs-identifier hs-var">join_ids</span></a></span></span><span>
</span><span id="line-755"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867908"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ae_joins :: IdSet
</span><a href="GHC.Core.Opt.Arity.html#ae_joins"><span class="hs-identifier hs-var">ae_joins</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdSet
</span><a href="#local-6989586621680867907"><span class="hs-identifier hs-var">joins</span></a></span><span> </span><span class="annot"><span class="annottext">IdSet -&gt; [Id] -&gt; IdSet
</span><a href="GHC.Types.Var.Set.html#extendVarSetList"><span class="hs-operator hs-var">`extendVarSetList`</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867906"><span class="hs-identifier hs-var">join_ids</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-756"></span><span>
</span><span id="line-757"></span><span class="hs-comment">----------------</span><span>
</span><span id="line-758"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-type">arityType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityEnv"><span class="hs-identifier hs-type">ArityEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span>
</span><span id="line-759"></span><span>
</span><span id="line-760"></span><span id="arityType"><span class="annot"><span class="annottext">arityType :: ArityEnv -&gt; CoreExpr -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var hs-var">arityType</span></a></span></span><span> </span><span id="local-6989586621680867904"><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867904"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-type">Cast</span></a></span><span> </span><span id="local-6989586621680867903"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867903"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span id="local-6989586621680867902"><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867902"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-761"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ArityEnv -&gt; CoreExpr -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867904"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867903"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-762"></span><span>      </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-type">ATop</span></a></span><span> </span><span id="local-6989586621680867901"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867901"><span class="hs-identifier hs-var">os</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-var">ATop</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity -&gt; [OneShotInfo] -&gt; [OneShotInfo]
forall a. JoinArity -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#take"><span class="hs-identifier hs-var">take</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867900"><span class="hs-identifier hs-var">co_arity</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867901"><span class="hs-identifier hs-var">os</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- See Note [Arity trimming]</span><span>
</span><span id="line-763"></span><span>      </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-type">ABot</span></a></span><span> </span><span id="local-6989586621680867899"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867899"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867900"><span class="hs-identifier hs-var">co_arity</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;</span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867899"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-var">ATop</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity -&gt; OneShotInfo -&gt; [OneShotInfo]
forall a. JoinArity -&gt; a -&gt; [a]
</span><a href="../../base/src/GHC.List.html#replicate"><span class="hs-identifier hs-var">replicate</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867900"><span class="hs-identifier hs-var">co_arity</span></a></span><span> </span><span class="annot"><span class="annottext">OneShotInfo
</span><a href="GHC.Types.Basic.html#noOneShotInfo"><span class="hs-identifier hs-var">noOneShotInfo</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-764"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-var">ABot</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867899"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-765"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-766"></span><span>    </span><span id="local-6989586621680867900"><span class="annot"><span class="annottext">co_arity :: JoinArity
</span><a href="#local-6989586621680867900"><span class="hs-identifier hs-var hs-var">co_arity</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; JoinArity
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; JoinArity
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; [OneShotInfo]
</span><a href="GHC.Core.Opt.Arity.html#typeArity"><span class="hs-identifier hs-var">typeArity</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoercionR -&gt; Type
</span><a href="GHC.Core.Coercion.html#coercionRKind"><span class="hs-identifier hs-var">coercionRKind</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867902"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-767"></span><span>    </span><span class="hs-comment">-- See Note [exprArity invariant] (2); must be true of</span><span>
</span><span id="line-768"></span><span>    </span><span class="hs-comment">-- arityType too, since that is how we compute the arity</span><span>
</span><span id="line-769"></span><span>    </span><span class="hs-comment">-- of variables, and they in turn affect result of exprArity</span><span>
</span><span id="line-770"></span><span>    </span><span class="hs-comment">-- #5441 is a nice demo</span><span>
</span><span id="line-771"></span><span>    </span><span class="hs-comment">-- However, do make sure that ATop -&gt; ATop and ABot -&gt; ABot!</span><span>
</span><span id="line-772"></span><span>    </span><span class="hs-comment">--   Casts don't affect that part. Getting this wrong provoked #5475</span><span>
</span><span id="line-773"></span><span>
</span><span id="line-774"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span id="local-6989586621680867896"><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867896"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621680867895"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867895"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-775"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867895"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; IdSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv -&gt; IdSet
</span><a href="GHC.Core.Opt.Arity.html#ae_joins"><span class="hs-identifier hs-var hs-var">ae_joins</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867896"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-776"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ArityType
</span><a href="GHC.Core.Opt.Arity.html#botArityType"><span class="hs-identifier hs-var">botArityType</span></a></span><span>  </span><span class="hs-comment">-- See Note [Eta-expansion and join points]</span><span>
</span><span id="line-777"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-778"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#idArityType"><span class="hs-identifier hs-var">idArityType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867895"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-779"></span><span>
</span><span id="line-780"></span><span>        </span><span class="hs-comment">-- Lambdas; increase arity</span><span>
</span><span id="line-781"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span id="local-6989586621680867893"><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867893"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-type">Lam</span></a></span><span> </span><span id="local-6989586621680867892"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867892"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621680867891"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867891"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-782"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867892"><span class="hs-identifier hs-var">x</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; ArityType -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#arityLam"><span class="hs-identifier hs-var">arityLam</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867892"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ArityEnv -&gt; CoreExpr -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867893"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867891"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-783"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ArityEnv -&gt; CoreExpr -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867893"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867891"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-784"></span><span>
</span><span id="line-785"></span><span>        </span><span class="hs-comment">-- Applications; decrease arity, except for types</span><span>
</span><span id="line-786"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span id="local-6989586621680867890"><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867890"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#App"><span class="hs-identifier hs-type">App</span></a></span><span> </span><span id="local-6989586621680867889"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867889"><span class="hs-identifier hs-var">fun</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-787"></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ArityEnv -&gt; CoreExpr -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867890"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867889"><span class="hs-identifier hs-var">fun</span></a></span><span>
</span><span id="line-788"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span id="local-6989586621680867888"><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867888"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#App"><span class="hs-identifier hs-type">App</span></a></span><span> </span><span id="local-6989586621680867887"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867887"><span class="hs-identifier hs-var">fun</span></a></span></span><span> </span><span id="local-6989586621680867886"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867886"><span class="hs-identifier hs-var">arg</span></a></span></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-789"></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ArityType -&gt; Bool -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#arityApp"><span class="hs-identifier hs-var">arityApp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ArityEnv -&gt; CoreExpr -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867888"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867887"><span class="hs-identifier hs-var">fun</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ArityEnv -&gt; CheapFun
</span><a href="GHC.Core.Opt.Arity.html#ae_cheap_fn"><span class="hs-identifier hs-var hs-var">ae_cheap_fn</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867888"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867886"><span class="hs-identifier hs-var">arg</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Type
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-790"></span><span>
</span><span id="line-791"></span><span>        </span><span class="hs-comment">-- Case/Let; keep arity if either the expression is cheap</span><span>
</span><span id="line-792"></span><span>        </span><span class="hs-comment">-- or it's a 1-shot lambda</span><span>
</span><span id="line-793"></span><span>        </span><span class="hs-comment">-- The former is not really right for Haskell</span><span>
</span><span id="line-794"></span><span>        </span><span class="hs-comment">--      f x = case x of { (a,b) -&gt; \y. e }</span><span>
</span><span id="line-795"></span><span>        </span><span class="hs-comment">--  ===&gt;</span><span>
</span><span id="line-796"></span><span>        </span><span class="hs-comment">--      f x y = case x of { (a,b) -&gt; e }</span><span>
</span><span id="line-797"></span><span>        </span><span class="hs-comment">-- The difference is observable using 'seq'</span><span>
</span><span id="line-798"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-799"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span id="local-6989586621680867885"><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867885"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Case"><span class="hs-identifier hs-type">Case</span></a></span><span> </span><span id="local-6989586621680867883"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867883"><span class="hs-identifier hs-var">scrut</span></a></span></span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680867882"><span class="annot"><span class="annottext">[Alt Id]
</span><a href="#local-6989586621680867882"><span class="hs-identifier hs-var">alts</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-800"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Bool
</span><a href="GHC.Core.Utils.html#exprIsDeadEnd"><span class="hs-identifier hs-var">exprIsDeadEnd</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867883"><span class="hs-identifier hs-var">scrut</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">[Alt Id] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[Alt Id]
</span><a href="#local-6989586621680867882"><span class="hs-identifier hs-var">alts</span></a></span><span>
</span><span id="line-801"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ArityType
</span><a href="GHC.Core.Opt.Arity.html#botArityType"><span class="hs-identifier hs-var">botArityType</span></a></span><span>    </span><span class="hs-comment">-- Do not eta expand</span><span>
</span><span id="line-802"></span><span>                    </span><span class="hs-comment">-- See Note [Dealing with bottom (1)]</span><span>
</span><span id="line-803"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-804"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">ArityType
</span><a href="#local-6989586621680867880"><span class="hs-identifier hs-var">alts_type</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-805"></span><span>     </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-type">ABot</span></a></span><span> </span><span id="local-6989586621680867879"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867879"><span class="hs-identifier hs-var">n</span></a></span></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867879"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-var">ATop</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>       </span><span class="hs-comment">-- Don't eta expand</span><span>
</span><span id="line-806"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ArityType
</span><a href="GHC.Core.Opt.Arity.html#botArityType"><span class="hs-identifier hs-var">botArityType</span></a></span><span>  </span><span class="hs-comment">-- if RHS is bottomming</span><span>
</span><span id="line-807"></span><span>                                          </span><span class="hs-comment">-- See Note [Dealing with bottom (2)]</span><span>
</span><span id="line-808"></span><span>
</span><span id="line-809"></span><span>     </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-type">ATop</span></a></span><span> </span><span id="local-6989586621680867877"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867877"><span class="hs-keyword hs-var">as</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ArityEnv -&gt; Bool
</span><a href="GHC.Core.Opt.Arity.html#ae_ped_bot"><span class="hs-identifier hs-var hs-var">ae_ped_bot</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867885"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>    </span><span class="hs-comment">-- See Note [Dealing with bottom (3)]</span><span>
</span><span id="line-810"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ArityEnv -&gt; CheapFun
</span><a href="GHC.Core.Opt.Arity.html#ae_cheap_fn"><span class="hs-identifier hs-var hs-var">ae_cheap_fn</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867885"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867883"><span class="hs-identifier hs-var">scrut</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Type
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-var">ATop</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867877"><span class="hs-keyword hs-var">as</span></a></span><span>
</span><span id="line-811"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Bool
</span><a href="GHC.Core.Utils.html#exprOkForSpeculation"><span class="hs-identifier hs-var">exprOkForSpeculation</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867883"><span class="hs-identifier hs-var">scrut</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-var">ATop</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867877"><span class="hs-keyword hs-var">as</span></a></span><span>
</span><span id="line-812"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-var">ATop</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(OneShotInfo -&gt; Bool) -&gt; [OneShotInfo] -&gt; [OneShotInfo]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#takeWhile"><span class="hs-identifier hs-var">takeWhile</span></a></span><span> </span><span class="annot"><span class="annottext">OneShotInfo -&gt; Bool
</span><a href="GHC.Types.Basic.html#isOneShotInfo"><span class="hs-identifier hs-var">isOneShotInfo</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867877"><span class="hs-keyword hs-var">as</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-813"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-814"></span><span>    </span><span id="local-6989586621680867880"><span class="annot"><span class="annottext">alts_type :: ArityType
</span><a href="#local-6989586621680867880"><span class="hs-identifier hs-var hs-var">alts_type</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(ArityType -&gt; ArityType -&gt; ArityType) -&gt; [ArityType] -&gt; ArityType
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; a -&gt; a) -&gt; t a -&gt; a
</span><a href="../../base/src/Data.Foldable.html#foldr1"><span class="hs-identifier hs-var">foldr1</span></a></span><span> </span><span class="annot"><span class="annottext">ArityType -&gt; ArityType -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#andArityType"><span class="hs-identifier hs-var">andArityType</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">ArityEnv -&gt; CoreExpr -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867885"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867873"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AltCon
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">[Id]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621680867873"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867873"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Alt Id]
</span><a href="#local-6989586621680867882"><span class="hs-identifier hs-var">alts</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-815"></span><span>
</span><span id="line-816"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span id="local-6989586621680867872"><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867872"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Let"><span class="hs-identifier hs-type">Let</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-type">NonRec</span></a></span><span> </span><span id="local-6989586621680867869"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867869"><span class="hs-identifier hs-var">j</span></a></span></span><span> </span><span id="local-6989586621680867868"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867868"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680867867"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867867"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-817"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680867866"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867866"><span class="hs-identifier hs-var">join_arity</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Maybe JoinArity
</span><a href="GHC.Types.Id.html#isJoinId_maybe"><span class="hs-identifier hs-var">isJoinId_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867869"><span class="hs-identifier hs-var">j</span></a></span><span>
</span><span id="line-818"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867864"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867864"><span class="hs-identifier hs-var">rhs_body</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; CoreExpr -&gt; ([Id], CoreExpr)
forall b. JoinArity -&gt; Expr b -&gt; ([b], Expr b)
</span><a href="GHC.Core.html#collectNBinders"><span class="hs-identifier hs-var">collectNBinders</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867866"><span class="hs-identifier hs-var">join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867868"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-819"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- See Note [Eta-expansion and join points]</span><span>
</span><span id="line-820"></span><span>    </span><span class="annot"><span class="annottext">ArityType -&gt; ArityType -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#andArityType"><span class="hs-identifier hs-var">andArityType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ArityEnv -&gt; CoreExpr -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867872"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867864"><span class="hs-identifier hs-var">rhs_body</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-821"></span><span>                 </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ArityEnv -&gt; CoreExpr -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867862"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867867"><span class="hs-identifier hs-var">body</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-822"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-823"></span><span>     </span><span id="local-6989586621680867862"><span class="annot"><span class="annottext">env' :: ArityEnv
</span><a href="#local-6989586621680867862"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ArityEnv -&gt; [Id] -&gt; ArityEnv
</span><a href="GHC.Core.Opt.Arity.html#extendJoinEnv"><span class="hs-identifier hs-var">extendJoinEnv</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867872"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867869"><span class="hs-identifier hs-var">j</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-824"></span><span>
</span><span id="line-825"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span id="local-6989586621680867861"><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867861"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Let"><span class="hs-identifier hs-type">Let</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-type">Rec</span></a></span><span> </span><span id="local-6989586621680867859"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680867859"><span class="hs-identifier hs-var">pairs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680867858"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867858"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-826"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621680867857"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867857"><span class="hs-identifier hs-var">j</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">CoreExpr
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680867859"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-827"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Id.html#isJoinId"><span class="hs-identifier hs-var">isJoinId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867857"><span class="hs-identifier hs-var">j</span></a></span><span>
</span><span id="line-828"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- See Note [Eta-expansion and join points]</span><span>
</span><span id="line-829"></span><span>    </span><span class="annot"><span class="annottext">((Id, CoreExpr) -&gt; ArityType -&gt; ArityType)
-&gt; ArityType -&gt; [(Id, CoreExpr)] -&gt; ArityType
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ArityType -&gt; ArityType -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#andArityType"><span class="hs-identifier hs-var">andArityType</span></a></span><span> </span><span class="annot"><span class="annottext">(ArityType -&gt; ArityType -&gt; ArityType)
-&gt; ((Id, CoreExpr) -&gt; ArityType)
-&gt; (Id, CoreExpr)
-&gt; ArityType
-&gt; ArityType
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(Id, CoreExpr) -&gt; ArityType
</span><a href="#local-6989586621680867853"><span class="hs-identifier hs-var">do_one</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ArityEnv -&gt; CoreExpr -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867852"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867858"><span class="hs-identifier hs-var">body</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680867859"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-830"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-831"></span><span>    </span><span id="local-6989586621680867852"><span class="annot"><span class="annottext">env' :: ArityEnv
</span><a href="#local-6989586621680867852"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ArityEnv -&gt; [Id] -&gt; ArityEnv
</span><a href="GHC.Core.Opt.Arity.html#extendJoinEnv"><span class="hs-identifier hs-var">extendJoinEnv</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867861"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((Id, CoreExpr) -&gt; Id) -&gt; [(Id, CoreExpr)] -&gt; [Id]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Id, CoreExpr) -&gt; Id
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680867859"><span class="hs-identifier hs-var">pairs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-832"></span><span>    </span><span id="local-6989586621680867853"><span class="annot"><span class="annottext">do_one :: (Id, CoreExpr) -&gt; ArityType
</span><a href="#local-6989586621680867853"><span class="hs-identifier hs-var hs-var">do_one</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680867840"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867840"><span class="hs-identifier hs-var">j</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680867839"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867839"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-833"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680867838"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867838"><span class="hs-identifier hs-var">arity</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Maybe JoinArity
</span><a href="GHC.Types.Id.html#isJoinId_maybe"><span class="hs-identifier hs-var">isJoinId_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867840"><span class="hs-identifier hs-var">j</span></a></span><span>
</span><span id="line-834"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ArityEnv -&gt; CoreExpr -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867852"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreExpr -&gt; ArityType) -&gt; CoreExpr -&gt; ArityType
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">([Id], CoreExpr) -&gt; CoreExpr
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="annot"><span class="annottext">(([Id], CoreExpr) -&gt; CoreExpr) -&gt; ([Id], CoreExpr) -&gt; CoreExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; CoreExpr -&gt; ([Id], CoreExpr)
forall b. JoinArity -&gt; Expr b -&gt; ([b], Expr b)
</span><a href="GHC.Core.html#collectNBinders"><span class="hs-identifier hs-var">collectNBinders</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867838"><span class="hs-identifier hs-var">arity</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867839"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-835"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-836"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; ArityType
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;arityType:joinrec&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(Id, CoreExpr)] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680867859"><span class="hs-identifier hs-var">pairs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-837"></span><span>
</span><span id="line-838"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span id="local-6989586621680867836"><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867836"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Let"><span class="hs-identifier hs-type">Let</span></a></span><span> </span><span id="local-6989586621680867835"><span class="annot"><span class="annottext">Bind Id
</span><a href="#local-6989586621680867835"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621680867834"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867834"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-839"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; ArityType -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#floatIn"><span class="hs-identifier hs-var">floatIn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bind Id -&gt; Bool
</span><a href="#local-6989586621680867833"><span class="hs-identifier hs-var">cheap_bind</span></a></span><span> </span><span class="annot"><span class="annottext">Bind Id
</span><a href="#local-6989586621680867835"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ArityEnv -&gt; CoreExpr -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867836"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867834"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-840"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-841"></span><span>    </span><span id="local-6989586621680867833"><span class="annot"><span class="annottext">cheap_bind :: Bind Id -&gt; Bool
</span><a href="#local-6989586621680867833"><span class="hs-identifier hs-var hs-var">cheap_bind</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-type">NonRec</span></a></span><span> </span><span id="local-6989586621680867831"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867831"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621680867830"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867830"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id, CoreExpr) -&gt; Bool
</span><a href="#local-6989586621680867829"><span class="hs-identifier hs-var">is_cheap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867831"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867830"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-842"></span><span>    </span><span class="annot"><a href="#local-6989586621680867833"><span class="hs-identifier hs-var">cheap_bind</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-type">Rec</span></a></span><span> </span><span id="local-6989586621680867828"><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680867828"><span class="hs-identifier hs-var">prs</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((Id, CoreExpr) -&gt; Bool) -&gt; [(Id, CoreExpr)] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">(Id, CoreExpr) -&gt; Bool
</span><a href="#local-6989586621680867829"><span class="hs-identifier hs-var">is_cheap</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, CoreExpr)]
</span><a href="#local-6989586621680867828"><span class="hs-identifier hs-var">prs</span></a></span><span>
</span><span id="line-843"></span><span>    </span><span id="local-6989586621680867829"><span class="annot"><span class="annottext">is_cheap :: (Id, CoreExpr) -&gt; Bool
</span><a href="#local-6989586621680867829"><span class="hs-identifier hs-var hs-var">is_cheap</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680867826"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867826"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680867825"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867825"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ArityEnv -&gt; CheapFun
</span><a href="GHC.Core.Opt.Arity.html#ae_cheap_fn"><span class="hs-identifier hs-var hs-var">ae_cheap_fn</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867836"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867825"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Maybe Type
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867826"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-844"></span><span>
</span><span id="line-845"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span id="local-6989586621680867823"><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867823"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-type">Tick</span></a></span><span> </span><span id="local-6989586621680867822"><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680867822"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span id="local-6989586621680867821"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867821"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-846"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tickish Id -&gt; Bool
forall id. Tickish id -&gt; Bool
</span><a href="GHC.Core.html#tickishIsCode"><span class="hs-identifier hs-var">tickishIsCode</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680867822"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ArityEnv -&gt; CoreExpr -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><a href="#local-6989586621680867823"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867821"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-847"></span><span>
</span><span id="line-848"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#arityType"><span class="hs-identifier hs-var">arityType</span></a></span><span> </span><span class="annot"><span class="annottext">ArityEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ArityType
</span><a href="GHC.Core.Opt.Arity.html#vanillaArityType"><span class="hs-identifier hs-var">vanillaArityType</span></a></span><span>
</span><span id="line-849"></span><span>
</span><span id="line-850"></span><span class="hs-comment">{- Note [Eta-expansion and join points]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider this (#18328)

  f x = join j y = case y of
                      True -&gt; \a. blah
                      False -&gt; \b. blah
        in case x of
              A -&gt; j True
              B -&gt; \c. blah
              C -&gt; j False

and suppose the join point is too big to inline.  Now, what is the
arity of f?  If we inlined the join point, we'd definitely say &quot;arity
2&quot; because we are prepared to push case-scrutinisation inside a
lambda.  But currently the join point totally messes all that up,
because (thought of as a vanilla let-binding) the arity pinned on 'j'
is just 1.

Why don't we eta-expand j?  Because of
Note [Do not eta-expand join points] in GHC.Core.Opt.Simplify.Utils

Even if we don't eta-expand j, why is its arity only 1?
See invariant 2b in Note [Invariants on join points] in GHC.Core.

So we do this:

* Treat the RHS of a join-point binding, /after/ stripping off
  join-arity lambda-binders, as very like the body of the let.
  More precisely, do andArityType with the arityType from the
  body of the let.

* Dually, when we come to a /call/ of a join point, just no-op
  by returning botArityType, the bottom element of ArityType,
  which so that: bot `andArityType` x = x

* This works if the join point is bound in the expression we are
  taking the arityType of.  But if it's bound further out, it makes
  no sense to say that (say) the arityType of (j False) is ABot 0.
  Bad things happen.  So we keep track of the in-scope join-point Ids
  in ae_join.

This will make f, above, have arity 2. Then, we'll eta-expand it thus:

  f x eta = (join j y = ... in case x of ...) eta

and the Simplify will automatically push that application of eta into
the join points.

An alternative (roughly equivalent) idea would be to carry an
environment mapping let-bound Ids to their ArityType.
-}</span><span>
</span><span id="line-902"></span><span>
</span><span id="line-903"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#idArityType"><span class="hs-identifier hs-type">idArityType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span>
</span><span id="line-904"></span><span id="idArityType"><span class="annot"><span class="annottext">idArityType :: Id -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#idArityType"><span class="hs-identifier hs-var hs-var">idArityType</span></a></span></span><span> </span><span id="local-6989586621680867820"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867820"><span class="hs-identifier hs-var">v</span></a></span></span><span>
</span><span id="line-905"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621680867819"><span class="annot"><span class="annottext">StrictSig
</span><a href="#local-6989586621680867819"><span class="hs-identifier hs-var">strict_sig</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id -&gt; StrictSig
</span><a href="GHC.Types.Id.html#idStrictness"><span class="hs-identifier hs-var">idStrictness</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867820"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-906"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; Bool -&gt; Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">StrictSig -&gt; Bool
</span><a href="GHC.Types.Demand.html#isTopSig"><span class="hs-identifier hs-var">isTopSig</span></a></span><span> </span><span class="annot"><span class="annottext">StrictSig
</span><a href="#local-6989586621680867819"><span class="hs-identifier hs-var">strict_sig</span></a></span><span>
</span><span id="line-907"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680867816"><span class="annot"><span class="annottext">[Demand]
</span><a href="#local-6989586621680867816"><span class="hs-identifier hs-var">ds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867815"><span class="annot"><span class="annottext">Divergence
</span><a href="#local-6989586621680867815"><span class="hs-identifier hs-var">res</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">StrictSig -&gt; ([Demand], Divergence)
</span><a href="GHC.Types.Demand.html#splitStrictSig"><span class="hs-identifier hs-var">splitStrictSig</span></a></span><span> </span><span class="annot"><span class="annottext">StrictSig
</span><a href="#local-6989586621680867819"><span class="hs-identifier hs-var">strict_sig</span></a></span><span>
</span><span id="line-908"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680867812"><span class="annot"><span class="annottext">arity :: JoinArity
</span><a href="#local-6989586621680867812"><span class="hs-identifier hs-var hs-var">arity</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Demand] -&gt; JoinArity
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; JoinArity
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[Demand]
</span><a href="#local-6989586621680867816"><span class="hs-identifier hs-var">ds</span></a></span><span>
</span><span id="line-909"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Divergence -&gt; Bool
</span><a href="GHC.Types.Demand.html#isDeadEndDiv"><span class="hs-identifier hs-var">isDeadEndDiv</span></a></span><span> </span><span class="annot"><span class="annottext">Divergence
</span><a href="#local-6989586621680867815"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ABot"><span class="hs-identifier hs-var">ABot</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867812"><span class="hs-identifier hs-var">arity</span></a></span><span>
</span><span id="line-910"></span><span>                        </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-var">ATop</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity -&gt; [OneShotInfo] -&gt; [OneShotInfo]
forall a. JoinArity -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#take"><span class="hs-identifier hs-var">take</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867812"><span class="hs-identifier hs-var">arity</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867810"><span class="hs-identifier hs-var">one_shots</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-911"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-912"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; ArityType
</span><a href="GHC.Core.Opt.Arity.html#ATop"><span class="hs-identifier hs-var">ATop</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity -&gt; [OneShotInfo] -&gt; [OneShotInfo]
forall a. JoinArity -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#take"><span class="hs-identifier hs-var">take</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; JoinArity
</span><a href="GHC.Types.Id.html#idArity"><span class="hs-identifier hs-var">idArity</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867820"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867810"><span class="hs-identifier hs-var">one_shots</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-913"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-914"></span><span>    </span><span class="annot"><a href="#local-6989586621680867810"><span class="hs-identifier hs-type">one_shots</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Basic.html#OneShotInfo"><span class="hs-identifier hs-type">OneShotInfo</span></a></span><span class="hs-special">]</span><span>  </span><span class="hs-comment">-- One-shot-ness derived from the type</span><span>
</span><span id="line-915"></span><span>    </span><span id="local-6989586621680867810"><span class="annot"><span class="annottext">one_shots :: [OneShotInfo]
</span><a href="#local-6989586621680867810"><span class="hs-identifier hs-var hs-var">one_shots</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; [OneShotInfo]
</span><a href="GHC.Core.Opt.Arity.html#typeArity"><span class="hs-identifier hs-var">typeArity</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867820"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-916"></span><span>
</span><span id="line-917"></span><span class="hs-comment">{-
%************************************************************************
%*                                                                      *
              The main eta-expander
%*                                                                      *
%************************************************************************

We go for:
   f = \x1..xn -&gt; N  ==&gt;   f = \x1..xn y1..ym -&gt; N y1..ym
                                 (n &gt;= 0)

where (in both cases)

        * The xi can include type variables

        * The yi are all value variables

        * N is a NORMAL FORM (i.e. no redexes anywhere)
          wanting a suitable number of extra args.

The biggest reason for doing this is for cases like

        f = \x -&gt; case x of
                    True  -&gt; \y -&gt; e1
                    False -&gt; \y -&gt; e2

Here we want to get the lambdas together.  A good example is the nofib
program fibheaps, which gets 25% more allocation if you don't do this
eta-expansion.

We may have to sandwich some coerces between the lambdas
to make the types work.   exprEtaExpandArity looks through coerces
when computing arity; and etaExpand adds the coerces as necessary when
actually computing the expansion.

Note [No crap in eta-expanded code]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The eta expander is careful not to introduce &quot;crap&quot;.  In particular,
given a CoreExpr satisfying the 'CpeRhs' invariant (in CorePrep), it
returns a CoreExpr satisfying the same invariant. See Note [Eta
expansion and the CorePrep invariants] in CorePrep.

This means the eta-expander has to do a bit of on-the-fly
simplification but it's not too hard.  The alternative, of relying on
a subsequent clean-up phase of the Simplifier to de-crapify the result,
means you can't really use it in CorePrep, which is painful.

Note [Eta expansion for join points]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The no-crap rule is very tiresome to guarantee when
we have join points. Consider eta-expanding
   let j :: Int -&gt; Int -&gt; Bool
       j x = e
   in b

The simple way is
  \(y::Int). (let j x = e in b) y

The no-crap way is
  \(y::Int). let j' :: Int -&gt; Bool
                 j' x = e y
             in b[j'/j] y
where I have written to stress that j's type has
changed.  Note that (of course!) we have to push the application
inside the RHS of the join as well as into the body.  AND if j
has an unfolding we have to push it into there too.  AND j might
be recursive...

So for now I'm abandoning the no-crap rule in this case. I think
that for the use in CorePrep it really doesn't matter; and if
it does, then CoreToStg.myCollectArgs will fall over.

(Moreover, I think that casts can make the no-crap rule fail too.)

Note [Eta expansion and SCCs]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note that SCCs are not treated specially by etaExpand.  If we have
        etaExpand 2 (\x -&gt; scc &quot;foo&quot; e)
        = (\xy -&gt; (scc &quot;foo&quot; e) y)
So the costs of evaluating 'e' (not 'e y') are attributed to &quot;foo&quot;

Note [Eta expansion and source notes]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CorePrep puts floatable ticks outside of value applications, but not
type applications. As a result we might be trying to eta-expand an
expression like

  (src&lt;...&gt; v) @a

which we want to lead to code like

  \x -&gt; src&lt;...&gt; v @a x

This means that we need to look through type applications and be ready
to re-add floats on the top.

Note [Eta expansion with ArityType]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The etaExpandAT function takes an ArityType (not just an Arity) to
guide eta-expansion.  Why? Because we want to preserve one-shot info.
Consider
  foo = \x. case x of
              True  -&gt; (\s{os}. blah) |&gt; co
              False -&gt; wubble
We'll get an ArityType for foo of (ATop [NoOneShot,OneShot]).

Then we want to eta-expand to
  foo = \x. (\eta{os}. (case x of ...as before...) eta) |&gt; some_co

That 'eta' binder is fresh, and we really want it to have the
one-shot flag from the inner \s{osf}.  By expanding with the
ArityType gotten from analysing the RHS, we achieve this neatly.

This makes a big difference to the one-shot monad trick;
see Note [The one-shot state monad trick] in GHC.Core.Unify.
-}</span><span>
</span><span id="line-1033"></span><span>
</span><span id="line-1034"></span><span class="hs-comment">-- | @etaExpand n e@ returns an expression with</span><span>
</span><span id="line-1035"></span><span class="hs-comment">-- the same meaning as @e@, but with arity @n@.</span><span>
</span><span id="line-1036"></span><span class="hs-comment">--</span><span>
</span><span id="line-1037"></span><span class="hs-comment">-- Given:</span><span>
</span><span id="line-1038"></span><span class="hs-comment">--</span><span>
</span><span id="line-1039"></span><span class="hs-comment">-- &gt; e' = etaExpand n e</span><span>
</span><span id="line-1040"></span><span class="hs-comment">--</span><span>
</span><span id="line-1041"></span><span class="hs-comment">-- We should have that:</span><span>
</span><span id="line-1042"></span><span class="hs-comment">--</span><span>
</span><span id="line-1043"></span><span class="hs-comment">-- &gt; ty = exprType e = exprType e'</span><span>
</span><span id="line-1044"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaExpand"><span class="hs-identifier hs-type">etaExpand</span></a></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#Arity"><span class="hs-identifier hs-type">Arity</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>
</span><span id="line-1045"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaExpandAT"><span class="hs-identifier hs-type">etaExpandAT</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#ArityType"><span class="hs-identifier hs-type">ArityType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>
</span><span id="line-1046"></span><span>
</span><span id="line-1047"></span><span id="etaExpand"><span class="annot"><span class="annottext">etaExpand :: JoinArity -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Arity.html#etaExpand"><span class="hs-identifier hs-var hs-var">etaExpand</span></a></span></span><span>   </span><span id="local-6989586621680867809"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867809"><span class="hs-identifier hs-var">n</span></a></span></span><span>  </span><span id="local-6989586621680867808"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867808"><span class="hs-identifier hs-var">orig_expr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Arity.html#eta_expand"><span class="hs-identifier hs-var">eta_expand</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity -&gt; OneShotInfo -&gt; [OneShotInfo]
forall a. JoinArity -&gt; a -&gt; [a]
</span><a href="../../base/src/GHC.List.html#replicate"><span class="hs-identifier hs-var">replicate</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867809"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">OneShotInfo
</span><a href="GHC.Types.Basic.html#NoOneShotInfo"><span class="hs-identifier hs-var">NoOneShotInfo</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867808"><span class="hs-identifier hs-var">orig_expr</span></a></span><span>
</span><span id="line-1048"></span><span id="etaExpandAT"><span class="annot"><span class="annottext">etaExpandAT :: ArityType -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Arity.html#etaExpandAT"><span class="hs-identifier hs-var hs-var">etaExpandAT</span></a></span></span><span> </span><span id="local-6989586621680867806"><span class="annot"><span class="annottext">ArityType
</span><a href="#local-6989586621680867806"><span class="hs-identifier hs-var">at</span></a></span></span><span> </span><span id="local-6989586621680867805"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867805"><span class="hs-identifier hs-var">orig_expr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Arity.html#eta_expand"><span class="hs-identifier hs-var">eta_expand</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ArityType -&gt; [OneShotInfo]
</span><a href="GHC.Core.Opt.Arity.html#arityTypeOneShots"><span class="hs-identifier hs-var">arityTypeOneShots</span></a></span><span> </span><span class="annot"><span class="annottext">ArityType
</span><a href="#local-6989586621680867806"><span class="hs-identifier hs-var">at</span></a></span><span class="hs-special">)</span><span>      </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867805"><span class="hs-identifier hs-var">orig_expr</span></a></span><span>
</span><span id="line-1049"></span><span>                           </span><span class="hs-comment">-- See Note [Eta expansion with ArityType]</span><span>
</span><span id="line-1050"></span><span>
</span><span id="line-1051"></span><span class="hs-comment">-- etaExpand arity e = res</span><span>
</span><span id="line-1052"></span><span class="hs-comment">-- Then 'res' has at least 'arity' lambdas at the top</span><span>
</span><span id="line-1053"></span><span class="hs-comment">-- See Note [Eta expansion with ArityType]</span><span>
</span><span id="line-1054"></span><span class="hs-comment">--</span><span>
</span><span id="line-1055"></span><span class="hs-comment">-- etaExpand deals with for-alls. For example:</span><span>
</span><span id="line-1056"></span><span class="hs-comment">--              etaExpand 1 E</span><span>
</span><span id="line-1057"></span><span class="hs-comment">-- where  E :: forall a. a -&gt; a</span><span>
</span><span id="line-1058"></span><span class="hs-comment">-- would return</span><span>
</span><span id="line-1059"></span><span class="hs-comment">--      (/\b. \y::a -&gt; E b y)</span><span>
</span><span id="line-1060"></span><span class="hs-comment">--</span><span>
</span><span id="line-1061"></span><span class="hs-comment">-- It deals with coerces too, though they are now rare</span><span>
</span><span id="line-1062"></span><span class="hs-comment">-- so perhaps the extra code isn't worth it</span><span>
</span><span id="line-1063"></span><span>
</span><span id="line-1064"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#eta_expand"><span class="hs-identifier hs-type">eta_expand</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Basic.html#OneShotInfo"><span class="hs-identifier hs-type">OneShotInfo</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>
</span><span id="line-1065"></span><span id="eta_expand"><span class="annot"><span class="annottext">eta_expand :: [OneShotInfo] -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Arity.html#eta_expand"><span class="hs-identifier hs-var hs-var">eta_expand</span></a></span></span><span> </span><span id="local-6989586621680867804"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867804"><span class="hs-identifier hs-var">one_shots</span></a></span></span><span> </span><span id="local-6989586621680867803"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867803"><span class="hs-identifier hs-var">orig_expr</span></a></span></span><span>
</span><span id="line-1066"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621680867802"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867804"><span class="hs-identifier hs-var">one_shots</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867803"><span class="hs-identifier hs-var">orig_expr</span></a></span><span>
</span><span id="line-1067"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1068"></span><span>      </span><span class="hs-comment">-- Strip off existing lambdas and casts before handing off to mkEtaWW</span><span>
</span><span id="line-1069"></span><span>      </span><span class="hs-comment">-- Note [Eta expansion and SCCs]</span><span>
</span><span id="line-1070"></span><span>    </span><span id="local-6989586621680867802"><span class="annot"><span class="annottext">go :: [OneShotInfo] -&gt; CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621680867802"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span id="local-6989586621680867801"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867801"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867801"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-1071"></span><span>    </span><span class="annot"><a href="#local-6989586621680867802"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621680867800"><span class="annot"><span class="annottext">oss :: [OneShotInfo]
</span><a href="#local-6989586621680867800"><span class="hs-identifier hs-var">oss</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><span class="annottext">OneShotInfo
</span><span class="hs-identifier">_</span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680867799"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867799"><span class="hs-identifier hs-var">oss1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-type">Lam</span></a></span><span> </span><span id="local-6989586621680867798"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867798"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span id="local-6989586621680867797"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867797"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867798"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr -&gt; CoreExpr
forall b. b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-var">Lam</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867798"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621680867802"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867800"><span class="hs-identifier hs-var">oss</span></a></span><span>  </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867797"><span class="hs-identifier hs-var">body</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1072"></span><span>                                 </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr -&gt; CoreExpr
forall b. b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-var">Lam</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867798"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621680867802"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867799"><span class="hs-identifier hs-var">oss1</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867797"><span class="hs-identifier hs-var">body</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1073"></span><span>    </span><span class="annot"><a href="#local-6989586621680867802"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621680867795"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867795"><span class="hs-identifier hs-var">oss</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-type">Cast</span></a></span><span> </span><span id="local-6989586621680867794"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867794"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span id="local-6989586621680867793"><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867793"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoercionR -&gt; CoreExpr
forall b. Expr b -&gt; CoercionR -&gt; Expr b
</span><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-var">Cast</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[OneShotInfo] -&gt; CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621680867802"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867795"><span class="hs-identifier hs-var">oss</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867794"><span class="hs-identifier hs-var">expr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867793"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1074"></span><span>
</span><span id="line-1075"></span><span>    </span><span class="annot"><a href="#local-6989586621680867802"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621680867792"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867792"><span class="hs-identifier hs-var">oss</span></a></span></span><span> </span><span id="local-6989586621680867791"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867791"><span class="hs-identifier hs-var">expr</span></a></span></span><span>
</span><span id="line-1076"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- pprTrace &quot;ee&quot; (vcat [ppr orig_expr, ppr expr, ppr etas]) $</span><span>
</span><span id="line-1077"></span><span>        </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621680867790"><span class="hs-identifier hs-var">retick</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreExpr -&gt; CoreExpr) -&gt; CoreExpr -&gt; CoreExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[EtaInfo] -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Arity.html#etaInfoAbs"><span class="hs-identifier hs-var">etaInfoAbs</span></a></span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867788"><span class="hs-identifier hs-var">etas</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; CoreExpr -&gt; [EtaInfo] -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Arity.html#etaInfoApp"><span class="hs-identifier hs-var">etaInfoApp</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867786"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867785"><span class="hs-identifier hs-var">sexpr</span></a></span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867788"><span class="hs-identifier hs-var">etas</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1078"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-1079"></span><span>          </span><span id="local-6989586621680867784"><span class="annot"><span class="annottext">in_scope :: InScopeSet
</span><a href="#local-6989586621680867784"><span class="hs-identifier hs-var hs-var">in_scope</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier hs-var">mkInScopeSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; IdSet
</span><a href="GHC.Core.FVs.html#exprFreeVars"><span class="hs-identifier hs-var">exprFreeVars</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867791"><span class="hs-identifier hs-var">expr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1080"></span><span>          </span><span class="hs-special">(</span><span id="local-6989586621680867779"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680867779"><span class="hs-identifier hs-var">in_scope'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867788"><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867788"><span class="hs-identifier hs-var">etas</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
-&gt; SDoc -&gt; InScopeSet -&gt; Type -&gt; (InScopeSet, [EtaInfo])
</span><a href="GHC.Core.Opt.Arity.html#mkEtaWW"><span class="hs-identifier hs-var">mkEtaWW</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867792"><span class="hs-identifier hs-var">oss</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867803"><span class="hs-identifier hs-var">orig_expr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680867784"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; Type
</span><a href="GHC.Core.Utils.html#exprType"><span class="hs-identifier hs-var">exprType</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867791"><span class="hs-identifier hs-var">expr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1081"></span><span>          </span><span id="local-6989586621680867786"><span class="annot"><span class="annottext">subst' :: Subst
</span><a href="#local-6989586621680867786"><span class="hs-identifier hs-var hs-var">subst'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; Subst
</span><a href="GHC.Core.Subst.html#mkEmptySubst"><span class="hs-identifier hs-var">mkEmptySubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680867779"><span class="hs-identifier hs-var">in_scope'</span></a></span><span>
</span><span id="line-1082"></span><span>
</span><span id="line-1083"></span><span>          </span><span class="hs-comment">-- Find ticks behind type apps.</span><span>
</span><span id="line-1084"></span><span>          </span><span class="hs-comment">-- See Note [Eta expansion and source notes]</span><span>
</span><span id="line-1085"></span><span>          </span><span class="hs-special">(</span><span id="local-6989586621680867775"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867775"><span class="hs-identifier hs-var">expr'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867774"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680867774"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; (CoreExpr, [CoreExpr])
forall b. Expr b -&gt; (Expr b, [Expr b])
</span><a href="GHC.Core.html#collectArgs"><span class="hs-identifier hs-var">collectArgs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867791"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-1086"></span><span>          </span><span class="hs-special">(</span><span id="local-6989586621680867772"><span class="annot"><span class="annottext">[Tickish Id]
</span><a href="#local-6989586621680867772"><span class="hs-identifier hs-var">ticks</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867771"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867771"><span class="hs-identifier hs-var">expr''</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Tickish Id -&gt; Bool) -&gt; CoreExpr -&gt; ([Tickish Id], CoreExpr)
forall b. (Tickish Id -&gt; Bool) -&gt; Expr b -&gt; ([Tickish Id], Expr b)
</span><a href="GHC.Core.Utils.html#stripTicksTop"><span class="hs-identifier hs-var">stripTicksTop</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish Id -&gt; Bool
forall id. Tickish id -&gt; Bool
</span><a href="GHC.Core.html#tickishFloatable"><span class="hs-identifier hs-var">tickishFloatable</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867775"><span class="hs-identifier hs-var">expr'</span></a></span><span>
</span><span id="line-1087"></span><span>          </span><span id="local-6989586621680867785"><span class="annot"><span class="annottext">sexpr :: CoreExpr
</span><a href="#local-6989586621680867785"><span class="hs-identifier hs-var hs-var">sexpr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreExpr -&gt; CoreExpr -&gt; CoreExpr)
-&gt; CoreExpr -&gt; [CoreExpr] -&gt; CoreExpr
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoreExpr -&gt; CoreExpr
forall b. Expr b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#App"><span class="hs-identifier hs-var">App</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867771"><span class="hs-identifier hs-var">expr''</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680867774"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-1088"></span><span>          </span><span id="local-6989586621680867790"><span class="annot"><span class="annottext">retick :: CoreExpr -&gt; CoreExpr
</span><a href="#local-6989586621680867790"><span class="hs-identifier hs-var hs-var">retick</span></a></span></span><span> </span><span id="local-6989586621680867765"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867765"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Tickish Id -&gt; CoreExpr -&gt; CoreExpr)
-&gt; CoreExpr -&gt; [Tickish Id] -&gt; CoreExpr
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish Id -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Utils.html#mkTick"><span class="hs-identifier hs-var">mkTick</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867765"><span class="hs-identifier hs-var">expr</span></a></span><span> </span><span class="annot"><span class="annottext">[Tickish Id]
</span><a href="#local-6989586621680867772"><span class="hs-identifier hs-var">ticks</span></a></span><span>
</span><span id="line-1089"></span><span>
</span><span id="line-1090"></span><span>                                </span><span class="hs-comment">-- Abstraction    Application</span><span>
</span><span id="line-1091"></span><span class="hs-comment">--------------</span><span>
</span><span id="line-1092"></span><span class="hs-keyword">data</span><span> </span><span id="EtaInfo"><span class="annot"><a href="GHC.Core.Opt.Arity.html#EtaInfo"><span class="hs-identifier hs-var">EtaInfo</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="EtaVar"><span class="annot"><a href="GHC.Core.Opt.Arity.html#EtaVar"><span class="hs-identifier hs-var">EtaVar</span></a></span></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span>       </span><span class="hs-comment">-- /\a. []        [] a</span><span>
</span><span id="line-1093"></span><span>                                </span><span class="hs-comment">-- \x.  []        [] x</span><span>
</span><span id="line-1094"></span><span>             </span><span class="hs-glyph">|</span><span> </span><span id="EtaCo"><span class="annot"><a href="GHC.Core.Opt.Arity.html#EtaCo"><span class="hs-identifier hs-var">EtaCo</span></a></span></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span>   </span><span class="hs-comment">-- [] |&gt; sym co   [] |&gt; co</span><span>
</span><span id="line-1095"></span><span>
</span><span id="line-1096"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621680867757"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#EtaInfo"><span class="hs-identifier hs-type">EtaInfo</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-1097"></span><span>   </span><span id="local-6989586621680867753"><span class="annot"><span class="annottext">ppr :: EtaInfo -&gt; SDoc
</span><a href="#local-6989586621680867753"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#EtaVar"><span class="hs-identifier hs-type">EtaVar</span></a></span><span> </span><span id="local-6989586621680867752"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867752"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;EtaVar&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867752"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-1098"></span><span>   </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#EtaCo"><span class="hs-identifier hs-type">EtaCo</span></a></span><span> </span><span id="local-6989586621680867750"><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867750"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;EtaCo&quot;</span></span><span>  </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionR -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867750"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1099"></span><span>
</span><span id="line-1100"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#pushCoercion"><span class="hs-identifier hs-type">pushCoercion</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#EtaInfo"><span class="hs-identifier hs-type">EtaInfo</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#EtaInfo"><span class="hs-identifier hs-type">EtaInfo</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1101"></span><span id="pushCoercion"><span class="annot"><span class="annottext">pushCoercion :: CoercionR -&gt; [EtaInfo] -&gt; [EtaInfo]
</span><a href="GHC.Core.Opt.Arity.html#pushCoercion"><span class="hs-identifier hs-var hs-var">pushCoercion</span></a></span></span><span> </span><span id="local-6989586621680867748"><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867748"><span class="hs-identifier hs-var">co1</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#EtaCo"><span class="hs-identifier hs-type">EtaCo</span></a></span><span> </span><span id="local-6989586621680867747"><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867747"><span class="hs-identifier hs-var">co2</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680867746"><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867746"><span class="hs-identifier hs-var">eis</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1102"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoercionR -&gt; Bool
</span><a href="GHC.Core.Coercion.html#isReflCo"><span class="hs-identifier hs-var">isReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867744"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867746"><span class="hs-identifier hs-var">eis</span></a></span><span>
</span><span id="line-1103"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoercionR -&gt; EtaInfo
</span><a href="GHC.Core.Opt.Arity.html#EtaCo"><span class="hs-identifier hs-var">EtaCo</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867744"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="annot"><span class="annottext">EtaInfo -&gt; [EtaInfo] -&gt; [EtaInfo]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867746"><span class="hs-identifier hs-var">eis</span></a></span><span>
</span><span id="line-1104"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1105"></span><span>    </span><span id="local-6989586621680867744"><span class="annot"><span class="annottext">co :: CoercionR
</span><a href="#local-6989586621680867744"><span class="hs-identifier hs-var hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867748"><span class="hs-identifier hs-var">co1</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionR -&gt; CoercionR -&gt; CoercionR
</span><a href="GHC.Core.Coercion.html#mkTransCo"><span class="hs-operator hs-var">`mkTransCo`</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867747"><span class="hs-identifier hs-var">co2</span></a></span><span>
</span><span id="line-1106"></span><span>
</span><span id="line-1107"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#pushCoercion"><span class="hs-identifier hs-var">pushCoercion</span></a></span><span> </span><span id="local-6989586621680867742"><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867742"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span id="local-6989586621680867741"><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867741"><span class="hs-identifier hs-var">eis</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoercionR -&gt; EtaInfo
</span><a href="GHC.Core.Opt.Arity.html#EtaCo"><span class="hs-identifier hs-var">EtaCo</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867742"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="annot"><span class="annottext">EtaInfo -&gt; [EtaInfo] -&gt; [EtaInfo]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867741"><span class="hs-identifier hs-var">eis</span></a></span><span>
</span><span id="line-1108"></span><span>
</span><span id="line-1109"></span><span class="hs-comment">--------------</span><span>
</span><span id="line-1110"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaInfoAbs"><span class="hs-identifier hs-type">etaInfoAbs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#EtaInfo"><span class="hs-identifier hs-type">EtaInfo</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>
</span><span id="line-1111"></span><span id="etaInfoAbs"><span class="annot"><span class="annottext">etaInfoAbs :: [EtaInfo] -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Arity.html#etaInfoAbs"><span class="hs-identifier hs-var hs-var">etaInfoAbs</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>               </span><span id="local-6989586621680867740"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867740"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867740"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-1112"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaInfoAbs"><span class="hs-identifier hs-var">etaInfoAbs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#EtaVar"><span class="hs-identifier hs-type">EtaVar</span></a></span><span> </span><span id="local-6989586621680867739"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867739"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680867738"><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867738"><span class="hs-identifier hs-var">eis</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680867737"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867737"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreExpr -&gt; CoreExpr
forall b. b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-var">Lam</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867739"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[EtaInfo] -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Arity.html#etaInfoAbs"><span class="hs-identifier hs-var">etaInfoAbs</span></a></span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867738"><span class="hs-identifier hs-var">eis</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867737"><span class="hs-identifier hs-var">expr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1113"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaInfoAbs"><span class="hs-identifier hs-var">etaInfoAbs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#EtaCo"><span class="hs-identifier hs-type">EtaCo</span></a></span><span> </span><span id="local-6989586621680867736"><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867736"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680867735"><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867735"><span class="hs-identifier hs-var">eis</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680867734"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867734"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; CoercionR -&gt; CoreExpr
forall b. Expr b -&gt; CoercionR -&gt; Expr b
</span><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-var">Cast</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[EtaInfo] -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Arity.html#etaInfoAbs"><span class="hs-identifier hs-var">etaInfoAbs</span></a></span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867735"><span class="hs-identifier hs-var">eis</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867734"><span class="hs-identifier hs-var">expr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoercionR -&gt; CoercionR
</span><a href="GHC.Core.Coercion.html#mkSymCo"><span class="hs-identifier hs-var">mkSymCo</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867736"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1114"></span><span>
</span><span id="line-1115"></span><span class="hs-comment">--------------</span><span>
</span><span id="line-1116"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaInfoApp"><span class="hs-identifier hs-type">etaInfoApp</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#EtaInfo"><span class="hs-identifier hs-type">EtaInfo</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>
</span><span id="line-1117"></span><span class="hs-comment">-- (etaInfoApp s e eis) returns something equivalent to</span><span>
</span><span id="line-1118"></span><span class="hs-comment">--             ((substExpr s e) `appliedto` eis)</span><span>
</span><span id="line-1119"></span><span>
</span><span id="line-1120"></span><span id="etaInfoApp"><span class="annot"><span class="annottext">etaInfoApp :: Subst -&gt; CoreExpr -&gt; [EtaInfo] -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Arity.html#etaInfoApp"><span class="hs-identifier hs-var hs-var">etaInfoApp</span></a></span></span><span> </span><span id="local-6989586621680867732"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867732"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-type">Lam</span></a></span><span> </span><span id="local-6989586621680867731"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867731"><span class="hs-identifier hs-var">v1</span></a></span></span><span> </span><span id="local-6989586621680867730"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867730"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#EtaVar"><span class="hs-identifier hs-type">EtaVar</span></a></span><span> </span><span id="local-6989586621680867729"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867729"><span class="hs-identifier hs-var">v2</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680867728"><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867728"><span class="hs-identifier hs-var">eis</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1121"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; CoreExpr -&gt; [EtaInfo] -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Arity.html#etaInfoApp"><span class="hs-identifier hs-var">etaInfoApp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; Id -&gt; Subst
</span><a href="GHC.Core.Subst.html#extendSubstWithVar"><span class="hs-identifier hs-var">GHC.Core.Subst.extendSubstWithVar</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867732"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867731"><span class="hs-identifier hs-var">v1</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867729"><span class="hs-identifier hs-var">v2</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867730"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867728"><span class="hs-identifier hs-var">eis</span></a></span><span>
</span><span id="line-1122"></span><span>
</span><span id="line-1123"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaInfoApp"><span class="hs-identifier hs-var">etaInfoApp</span></a></span><span> </span><span id="local-6989586621680867726"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867726"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-type">Cast</span></a></span><span> </span><span id="local-6989586621680867725"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867725"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span id="local-6989586621680867724"><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867724"><span class="hs-identifier hs-var">co1</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680867723"><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867723"><span class="hs-identifier hs-var">eis</span></a></span></span><span>
</span><span id="line-1124"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; CoreExpr -&gt; [EtaInfo] -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Arity.html#etaInfoApp"><span class="hs-identifier hs-var">etaInfoApp</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867726"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867725"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoercionR -&gt; [EtaInfo] -&gt; [EtaInfo]
</span><a href="GHC.Core.Opt.Arity.html#pushCoercion"><span class="hs-identifier hs-var">pushCoercion</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867722"><span class="hs-identifier hs-var">co'</span></a></span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867723"><span class="hs-identifier hs-var">eis</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1125"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1126"></span><span>    </span><span id="local-6989586621680867722"><span class="annot"><span class="annottext">co' :: CoercionR
</span><a href="#local-6989586621680867722"><span class="hs-identifier hs-var hs-var">co'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; Subst -&gt; CoercionR -&gt; CoercionR
Subst -&gt; CoercionR -&gt; CoercionR
</span><a href="GHC.Core.Subst.html#substCo"><span class="hs-identifier hs-var">GHC.Core.Subst.substCo</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867726"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867724"><span class="hs-identifier hs-var">co1</span></a></span><span>
</span><span id="line-1127"></span><span>
</span><span id="line-1128"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaInfoApp"><span class="hs-identifier hs-var">etaInfoApp</span></a></span><span> </span><span id="local-6989586621680867718"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867718"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Case"><span class="hs-identifier hs-type">Case</span></a></span><span> </span><span id="local-6989586621680867717"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867717"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span id="local-6989586621680867716"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867716"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621680867715"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867715"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621680867714"><span class="annot"><span class="annottext">[Alt Id]
</span><a href="#local-6989586621680867714"><span class="hs-identifier hs-var">alts</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680867713"><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867713"><span class="hs-identifier hs-var">eis</span></a></span></span><span>
</span><span id="line-1129"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; Id -&gt; Type -&gt; [Alt Id] -&gt; CoreExpr
forall b. Expr b -&gt; b -&gt; Type -&gt; [Alt b] -&gt; Expr b
</span><a href="GHC.Core.html#Case"><span class="hs-identifier hs-var">Case</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Arity.html#subst_expr"><span class="hs-identifier hs-var">subst_expr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867718"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867717"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867711"><span class="hs-identifier hs-var">b1</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867710"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="annot"><span class="annottext">[Alt Id]
</span><a href="#local-6989586621680867709"><span class="hs-identifier hs-var">alts'</span></a></span><span>
</span><span id="line-1130"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1131"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680867708"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867708"><span class="hs-identifier hs-var">subst1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867711"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867711"><span class="hs-identifier hs-var">b1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; Id -&gt; (Subst, Id)
</span><a href="GHC.Core.Subst.html#substBndr"><span class="hs-identifier hs-var">substBndr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867718"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867716"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-1132"></span><span>    </span><span id="local-6989586621680867709"><span class="annot"><span class="annottext">alts' :: [Alt Id]
</span><a href="#local-6989586621680867709"><span class="hs-identifier hs-var hs-var">alts'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Alt Id -&gt; Alt Id) -&gt; [Alt Id] -&gt; [Alt Id]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Alt Id -&gt; Alt Id
forall {a}. (a, [Id], CoreExpr) -&gt; (a, [Id], CoreExpr)
</span><a href="#local-6989586621680867706"><span class="hs-identifier hs-var">subst_alt</span></a></span><span> </span><span class="annot"><span class="annottext">[Alt Id]
</span><a href="#local-6989586621680867714"><span class="hs-identifier hs-var">alts</span></a></span><span>
</span><span id="line-1133"></span><span>    </span><span id="local-6989586621680867710"><span class="annot"><span class="annottext">ty' :: Type
</span><a href="#local-6989586621680867710"><span class="hs-identifier hs-var hs-var">ty'</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; [EtaInfo] -&gt; Type
</span><a href="GHC.Core.Opt.Arity.html#etaInfoAppTy"><span class="hs-identifier hs-var">etaInfoAppTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; Type -&gt; Type
</span><a href="GHC.Core.Subst.html#substTy"><span class="hs-identifier hs-var">GHC.Core.Subst.substTy</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867718"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867715"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867713"><span class="hs-identifier hs-var">eis</span></a></span><span>
</span><span id="line-1134"></span><span>    </span><span id="local-6989586621680867706"><span class="annot"><span class="annottext">subst_alt :: (a, [Id], CoreExpr) -&gt; (a, [Id], CoreExpr)
</span><a href="#local-6989586621680867706"><span class="hs-identifier hs-var hs-var">subst_alt</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680867703"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680867703"><span class="hs-identifier hs-var">con</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867702"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867702"><span class="hs-identifier hs-var">bs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867701"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867701"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680867703"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867700"><span class="hs-identifier hs-var">bs'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; CoreExpr -&gt; [EtaInfo] -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Arity.html#etaInfoApp"><span class="hs-identifier hs-var">etaInfoApp</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867699"><span class="hs-identifier hs-var">subst2</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867701"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867713"><span class="hs-identifier hs-var">eis</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1135"></span><span>              </span><span class="hs-keyword">where</span><span>
</span><span id="line-1136"></span><span>                 </span><span class="hs-special">(</span><span id="local-6989586621680867699"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867699"><span class="hs-identifier hs-var">subst2</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680867700"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867700"><span class="hs-identifier hs-var">bs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; [Id] -&gt; (Subst, [Id])
</span><a href="GHC.Core.Subst.html#substBndrs"><span class="hs-identifier hs-var">substBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867708"><span class="hs-identifier hs-var">subst1</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867702"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-1137"></span><span>
</span><span id="line-1138"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaInfoApp"><span class="hs-identifier hs-var">etaInfoApp</span></a></span><span> </span><span id="local-6989586621680867697"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867697"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Let"><span class="hs-identifier hs-type">Let</span></a></span><span> </span><span id="local-6989586621680867696"><span class="annot"><span class="annottext">Bind Id
</span><a href="#local-6989586621680867696"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621680867695"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867695"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680867694"><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867694"><span class="hs-identifier hs-var">eis</span></a></span></span><span>
</span><span id="line-1139"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bind Id -&gt; Bool
</span><a href="GHC.Core.Utils.html#isJoinBind"><span class="hs-identifier hs-var">isJoinBind</span></a></span><span> </span><span class="annot"><span class="annottext">Bind Id
</span><a href="#local-6989586621680867696"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1140"></span><span>    </span><span class="hs-comment">-- See Note [Eta expansion for join points]</span><span>
</span><span id="line-1141"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bind Id -&gt; CoreExpr -&gt; CoreExpr
forall b. Bind b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Let"><span class="hs-identifier hs-var">Let</span></a></span><span> </span><span class="annot"><span class="annottext">Bind Id
</span><a href="#local-6989586621680867692"><span class="hs-identifier hs-var">b'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; CoreExpr -&gt; [EtaInfo] -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Arity.html#etaInfoApp"><span class="hs-identifier hs-var">etaInfoApp</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867691"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867695"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867694"><span class="hs-identifier hs-var">eis</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1142"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1143"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680867691"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867691"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867692"><span class="annot"><span class="annottext">Bind Id
</span><a href="#local-6989586621680867692"><span class="hs-identifier hs-var">b'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; Bind Id -&gt; (Subst, Bind Id)
Subst -&gt; Bind Id -&gt; (Subst, Bind Id)
</span><a href="GHC.Core.Subst.html#substBindSC"><span class="hs-identifier hs-var">substBindSC</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867697"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Bind Id
</span><a href="#local-6989586621680867696"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-1144"></span><span>
</span><span id="line-1145"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaInfoApp"><span class="hs-identifier hs-var">etaInfoApp</span></a></span><span> </span><span id="local-6989586621680867688"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867688"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-type">Tick</span></a></span><span> </span><span id="local-6989586621680867687"><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680867687"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span id="local-6989586621680867686"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867686"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680867685"><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867685"><span class="hs-identifier hs-var">eis</span></a></span></span><span>
</span><span id="line-1146"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tickish Id -&gt; CoreExpr -&gt; CoreExpr
forall b. Tickish Id -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-var">Tick</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; Tickish Id -&gt; Tickish Id
</span><a href="GHC.Core.Subst.html#substTickish"><span class="hs-identifier hs-var">substTickish</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867688"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680867687"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; CoreExpr -&gt; [EtaInfo] -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Arity.html#etaInfoApp"><span class="hs-identifier hs-var">etaInfoApp</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867688"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867686"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867685"><span class="hs-identifier hs-var">eis</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1147"></span><span>
</span><span id="line-1148"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaInfoApp"><span class="hs-identifier hs-var">etaInfoApp</span></a></span><span> </span><span id="local-6989586621680867683"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867683"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680867682"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867682"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-1149"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621680867681"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867681"><span class="hs-identifier hs-var">fun</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; (CoreExpr, [CoreExpr])
forall b. Expr b -&gt; (Expr b, [Expr b])
</span><a href="GHC.Core.html#collectArgs"><span class="hs-identifier hs-var">collectArgs</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867682"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-1150"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621680867680"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867680"><span class="hs-identifier hs-var">fun'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; Id -&gt; CoreExpr
Subst -&gt; Id -&gt; CoreExpr
</span><a href="GHC.Core.Subst.html#lookupIdSubst"><span class="hs-identifier hs-var">lookupIdSubst</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867683"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867681"><span class="hs-identifier hs-var">fun</span></a></span><span>
</span><span id="line-1151"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Id.html#isJoinId"><span class="hs-identifier hs-var">isJoinId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867680"><span class="hs-identifier hs-var">fun'</span></a></span><span>
</span><span id="line-1152"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Subst -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Arity.html#subst_expr"><span class="hs-identifier hs-var">subst_expr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867683"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867682"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-1153"></span><span>
</span><span id="line-1154"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaInfoApp"><span class="hs-identifier hs-var">etaInfoApp</span></a></span><span> </span><span id="local-6989586621680867678"><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867678"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680867677"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867677"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span id="local-6989586621680867676"><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867676"><span class="hs-identifier hs-var">eis</span></a></span></span><span>
</span><span id="line-1155"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr -&gt; [EtaInfo] -&gt; CoreExpr
forall {b}. Expr b -&gt; [EtaInfo] -&gt; Expr b
</span><a href="#local-6989586621680867675"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Subst -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Arity.html#subst_expr"><span class="hs-identifier hs-var">subst_expr</span></a></span><span> </span><span class="annot"><span class="annottext">Subst
</span><a href="#local-6989586621680867678"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867677"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867676"><span class="hs-identifier hs-var">eis</span></a></span><span>
</span><span id="line-1156"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1157"></span><span>    </span><span id="local-6989586621680867675"><span class="annot"><span class="annottext">go :: Expr b -&gt; [EtaInfo] -&gt; Expr b
</span><a href="#local-6989586621680867675"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621680867674"><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680867674"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>                  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680867674"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1158"></span><span>    </span><span class="annot"><a href="#local-6989586621680867675"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621680867673"><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680867673"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#EtaVar"><span class="hs-identifier hs-type">EtaVar</span></a></span><span> </span><span id="local-6989586621680867672"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867672"><span class="hs-identifier hs-var">v</span></a></span></span><span>    </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680867671"><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867671"><span class="hs-identifier hs-var">eis</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr b -&gt; [EtaInfo] -&gt; Expr b
</span><a href="#local-6989586621680867675"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Expr b -&gt; Expr b -&gt; Expr b
forall b. Expr b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#App"><span class="hs-identifier hs-var">App</span></a></span><span> </span><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680867673"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Expr b
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#varToCoreExpr"><span class="hs-identifier hs-var">varToCoreExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867672"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867671"><span class="hs-identifier hs-var">eis</span></a></span><span>
</span><span id="line-1159"></span><span>    </span><span class="annot"><a href="#local-6989586621680867675"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621680867669"><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680867669"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#EtaCo"><span class="hs-identifier hs-type">EtaCo</span></a></span><span> </span><span id="local-6989586621680867668"><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867668"><span class="hs-identifier hs-var">co</span></a></span></span><span>    </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680867667"><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867667"><span class="hs-identifier hs-var">eis</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr b -&gt; [EtaInfo] -&gt; Expr b
</span><a href="#local-6989586621680867675"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Expr b -&gt; CoercionR -&gt; Expr b
forall b. Expr b -&gt; CoercionR -&gt; Expr b
</span><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-var">Cast</span></a></span><span> </span><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680867669"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867668"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867667"><span class="hs-identifier hs-var">eis</span></a></span><span>
</span><span id="line-1160"></span><span>
</span><span id="line-1161"></span><span>
</span><span id="line-1162"></span><span class="hs-comment">--------------</span><span>
</span><span id="line-1163"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaInfoAppTy"><span class="hs-identifier hs-type">etaInfoAppTy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#EtaInfo"><span class="hs-identifier hs-type">EtaInfo</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-1164"></span><span class="hs-comment">-- If                    e :: ty</span><span>
</span><span id="line-1165"></span><span class="hs-comment">-- then   etaInfoApp e eis :: etaInfoApp ty eis</span><span>
</span><span id="line-1166"></span><span id="etaInfoAppTy"><span class="annot"><span class="annottext">etaInfoAppTy :: Type -&gt; [EtaInfo] -&gt; Type
</span><a href="GHC.Core.Opt.Arity.html#etaInfoAppTy"><span class="hs-identifier hs-var hs-var">etaInfoAppTy</span></a></span></span><span> </span><span id="local-6989586621680867666"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867666"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>               </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867666"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1167"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaInfoAppTy"><span class="hs-identifier hs-var">etaInfoAppTy</span></a></span><span> </span><span id="local-6989586621680867665"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867665"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#EtaVar"><span class="hs-identifier hs-type">EtaVar</span></a></span><span> </span><span id="local-6989586621680867664"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867664"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680867663"><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867663"><span class="hs-identifier hs-var">eis</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; [EtaInfo] -&gt; Type
</span><a href="GHC.Core.Opt.Arity.html#etaInfoAppTy"><span class="hs-identifier hs-var">etaInfoAppTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; CoreExpr -&gt; Type
</span><a href="GHC.Core.html#applyTypeToArg"><span class="hs-identifier hs-var">applyTypeToArg</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867665"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#varToCoreExpr"><span class="hs-identifier hs-var">varToCoreExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867664"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867663"><span class="hs-identifier hs-var">eis</span></a></span><span>
</span><span id="line-1168"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaInfoAppTy"><span class="hs-identifier hs-var">etaInfoAppTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span>  </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#EtaCo"><span class="hs-identifier hs-type">EtaCo</span></a></span><span> </span><span id="local-6989586621680867661"><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867661"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621680867660"><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867660"><span class="hs-identifier hs-var">eis</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; [EtaInfo] -&gt; Type
</span><a href="GHC.Core.Opt.Arity.html#etaInfoAppTy"><span class="hs-identifier hs-var">etaInfoAppTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoercionR -&gt; Type
</span><a href="GHC.Core.Coercion.html#coercionRKind"><span class="hs-identifier hs-var">coercionRKind</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867661"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867660"><span class="hs-identifier hs-var">eis</span></a></span><span>
</span><span id="line-1169"></span><span>
</span><span id="line-1170"></span><span class="hs-comment">--------------</span><span>
</span><span id="line-1171"></span><span class="hs-comment">-- | @mkEtaWW n _ fvs ty@ will compute the 'EtaInfo' necessary for eta-expanding</span><span>
</span><span id="line-1172"></span><span class="hs-comment">-- an expression @e :: ty@ to take @n@ value arguments, where @fvs@ are the</span><span>
</span><span id="line-1173"></span><span class="hs-comment">-- free variables of @e@.</span><span>
</span><span id="line-1174"></span><span class="hs-comment">--</span><span>
</span><span id="line-1175"></span><span class="hs-comment">-- Note that this function is entirely unconcerned about cost centres and other</span><span>
</span><span id="line-1176"></span><span class="hs-comment">-- semantically-irrelevant source annotations, so call sites must take care to</span><span>
</span><span id="line-1177"></span><span class="hs-comment">-- preserve that info. See Note [Eta expansion and SCCs].</span><span>
</span><span id="line-1178"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#mkEtaWW"><span class="hs-identifier hs-type">mkEtaWW</span></a></span><span>
</span><span id="line-1179"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Basic.html#OneShotInfo"><span class="hs-identifier hs-type">OneShotInfo</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1180"></span><span>  </span><span class="hs-comment">-- ^ How many value arguments to eta-expand</span><span>
</span><span id="line-1181"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-1182"></span><span>  </span><span class="hs-comment">-- ^ The pretty-printed original expression, for warnings.</span><span>
</span><span id="line-1183"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span>
</span><span id="line-1184"></span><span>  </span><span class="hs-comment">-- ^ A super-set of the free vars of the expression to eta-expand.</span><span>
</span><span id="line-1185"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-1186"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#EtaInfo"><span class="hs-identifier hs-type">EtaInfo</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1187"></span><span>  </span><span class="hs-comment">-- ^ The variables in 'EtaInfo' are fresh wrt. to the incoming 'InScopeSet'.</span><span>
</span><span id="line-1188"></span><span>  </span><span class="hs-comment">-- The outgoing 'InScopeSet' extends the incoming 'InScopeSet' with the</span><span>
</span><span id="line-1189"></span><span>  </span><span class="hs-comment">-- fresh variables in 'EtaInfo'.</span><span>
</span><span id="line-1190"></span><span>
</span><span id="line-1191"></span><span id="mkEtaWW"><span class="annot"><span class="annottext">mkEtaWW :: [OneShotInfo]
-&gt; SDoc -&gt; InScopeSet -&gt; Type -&gt; (InScopeSet, [EtaInfo])
</span><a href="GHC.Core.Opt.Arity.html#mkEtaWW"><span class="hs-identifier hs-var hs-var">mkEtaWW</span></a></span></span><span> </span><span id="local-6989586621680867659"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867659"><span class="hs-identifier hs-var">orig_oss</span></a></span></span><span> </span><span id="local-6989586621680867658"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621680867658"><span class="hs-identifier hs-var">ppr_orig_expr</span></a></span></span><span> </span><span id="local-6989586621680867657"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680867657"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680867656"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867656"><span class="hs-identifier hs-var">orig_ty</span></a></span></span><span>
</span><span id="line-1192"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
-&gt; [OneShotInfo]
-&gt; TCvSubst
-&gt; Type
-&gt; [EtaInfo]
-&gt; (InScopeSet, [EtaInfo])
</span><a href="#local-6989586621680867655"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867659"><span class="hs-identifier hs-var">orig_oss</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867654"><span class="hs-identifier hs-var">empty_subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867656"><span class="hs-identifier hs-var">orig_ty</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1193"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1194"></span><span>    </span><span id="local-6989586621680867654"><span class="annot"><span class="annottext">empty_subst :: TCvSubst
</span><a href="#local-6989586621680867654"><span class="hs-identifier hs-var hs-var">empty_subst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkEmptyTCvSubst"><span class="hs-identifier hs-var">mkEmptyTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680867657"><span class="hs-identifier hs-var">in_scope</span></a></span><span>
</span><span id="line-1195"></span><span>
</span><span id="line-1196"></span><span>    </span><span class="annot"><a href="#local-6989586621680867655"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>                </span><span class="hs-comment">-- For fresh names</span><span>
</span><span id="line-1197"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Basic.html#OneShotInfo"><span class="hs-identifier hs-type">OneShotInfo</span></a></span><span class="hs-special">]</span><span>      </span><span class="hs-comment">-- Number of value args to expand to</span><span>
</span><span id="line-1198"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>   </span><span class="hs-comment">-- We are really looking at subst(ty)</span><span>
</span><span id="line-1199"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#EtaInfo"><span class="hs-identifier hs-type">EtaInfo</span></a></span><span class="hs-special">]</span><span>          </span><span class="hs-comment">-- Accumulating parameter</span><span>
</span><span id="line-1200"></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Opt.Arity.html#EtaInfo"><span class="hs-identifier hs-type">EtaInfo</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1201"></span><span>    </span><span id="local-6989586621680867655"><span class="annot"><span class="annottext">go :: JoinArity
-&gt; [OneShotInfo]
-&gt; TCvSubst
-&gt; Type
-&gt; [EtaInfo]
-&gt; (InScopeSet, [EtaInfo])
</span><a href="#local-6989586621680867655"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span id="local-6989586621680867652"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867652"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680867651"><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867651"><span class="hs-identifier hs-var">eis</span></a></span></span><span>       </span><span class="hs-comment">-- See Note [exprArity invariant]</span><span>
</span><span id="line-1202"></span><span>       </span><span class="hs-comment">----------- Done!  No more expansion needed</span><span>
</span><span id="line-1203"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; InScopeSet
</span><a href="GHC.Core.TyCo.Subst.html#getTCvInScope"><span class="hs-identifier hs-var">getTCvInScope</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867652"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[EtaInfo] -&gt; [EtaInfo]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867651"><span class="hs-identifier hs-var">eis</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1204"></span><span>
</span><span id="line-1205"></span><span>    </span><span class="annot"><a href="#local-6989586621680867655"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621680867648"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867648"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621680867647"><span class="annot"><span class="annottext">oss :: [OneShotInfo]
</span><a href="#local-6989586621680867647"><span class="hs-identifier hs-var">oss</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621680867646"><span class="annot"><span class="annottext">OneShotInfo
</span><a href="#local-6989586621680867646"><span class="hs-identifier hs-var">one_shot</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680867645"><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867645"><span class="hs-identifier hs-var">oss1</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680867644"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867644"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680867643"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867643"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621680867642"><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867642"><span class="hs-identifier hs-var">eis</span></a></span></span><span>       </span><span class="hs-comment">-- See Note [exprArity invariant]</span><span>
</span><span id="line-1206"></span><span>       </span><span class="hs-comment">----------- Forall types  (forall a. ty)</span><span>
</span><span id="line-1207"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680867641"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867641"><span class="hs-identifier hs-var">tcv</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680867640"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867640"><span class="hs-identifier hs-var">ty'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (Id, Type)
</span><a href="GHC.Core.Type.html#splitForAllTy_maybe"><span class="hs-identifier hs-var">splitForAllTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867643"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1208"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680867639"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867639"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867638"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867638"><span class="hs-identifier hs-var">tcv'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Id -&gt; (TCvSubst, Id)
TCvSubst -&gt; Id -&gt; (TCvSubst, Id)
</span><a href="GHC.Core.TyCo.Subst.html#substVarBndr"><span class="hs-identifier hs-var">Type.substVarBndr</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867644"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867641"><span class="hs-identifier hs-var">tcv</span></a></span><span>
</span><span id="line-1209"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680867636"><span class="annot"><span class="annottext">oss' :: [OneShotInfo]
</span><a href="#local-6989586621680867636"><span class="hs-identifier hs-var hs-var">oss'</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isTyVar"><span class="hs-identifier hs-var">isTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867641"><span class="hs-identifier hs-var">tcv</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867647"><span class="hs-identifier hs-var">oss</span></a></span><span>
</span><span id="line-1210"></span><span>                  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867645"><span class="hs-identifier hs-var">oss1</span></a></span><span>
</span><span id="line-1211"></span><span>         </span><span class="hs-comment">-- A forall can bind a CoVar, in which case</span><span>
</span><span id="line-1212"></span><span>         </span><span class="hs-comment">-- we consume one of the [OneShotInfo]</span><span>
</span><span id="line-1213"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
-&gt; [OneShotInfo]
-&gt; TCvSubst
-&gt; Type
-&gt; [EtaInfo]
-&gt; (InScopeSet, [EtaInfo])
</span><a href="#local-6989586621680867655"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867648"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867636"><span class="hs-identifier hs-var">oss'</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867639"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867640"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; EtaInfo
</span><a href="GHC.Core.Opt.Arity.html#EtaVar"><span class="hs-identifier hs-var">EtaVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867638"><span class="hs-identifier hs-var">tcv'</span></a></span><span> </span><span class="annot"><span class="annottext">EtaInfo -&gt; [EtaInfo] -&gt; [EtaInfo]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867642"><span class="hs-identifier hs-var">eis</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1214"></span><span>
</span><span id="line-1215"></span><span>       </span><span class="hs-comment">----------- Function types  (t1 -&gt; t2)</span><span>
</span><span id="line-1216"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680867635"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867635"><span class="hs-identifier hs-var">mult</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867634"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867634"><span class="hs-identifier hs-var">arg_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867633"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867633"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (Type, Type, Type)
</span><a href="GHC.Core.Type.html#splitFunTy_maybe"><span class="hs-identifier hs-var">splitFunTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867643"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1217"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.Type.html#isTypeLevPoly"><span class="hs-identifier hs-var">isTypeLevPoly</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867634"><span class="hs-identifier hs-var">arg_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1218"></span><span>          </span><span class="hs-comment">-- See Note [Levity polymorphism invariants] in GHC.Core</span><span>
</span><span id="line-1219"></span><span>          </span><span class="hs-comment">-- See also test case typecheck/should_run/EtaExpandLevPoly</span><span>
</span><span id="line-1220"></span><span>
</span><span id="line-1221"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680867631"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867631"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867630"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867630"><span class="hs-identifier hs-var">eta_id</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; TCvSubst -&gt; Scaled Type -&gt; (TCvSubst, Id)
</span><a href="GHC.Core.Opt.Arity.html#freshEtaId"><span class="hs-identifier hs-var">freshEtaId</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867648"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867644"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Scaled Type
forall a. Type -&gt; a -&gt; Scaled a
</span><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-var">Scaled</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867635"><span class="hs-identifier hs-var">mult</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867634"><span class="hs-identifier hs-var">arg_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1222"></span><span>          </span><span class="hs-comment">-- Avoid free vars of the original expression</span><span>
</span><span id="line-1223"></span><span>
</span><span id="line-1224"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680867627"><span class="annot"><span class="annottext">eta_id' :: Id
</span><a href="#local-6989586621680867627"><span class="hs-identifier hs-var hs-var">eta_id'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867630"><span class="hs-identifier hs-var">eta_id</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; OneShotInfo -&gt; Id
</span><a href="GHC.Types.Id.html#setIdOneShotInfo"><span class="hs-operator hs-var">`setIdOneShotInfo`</span></a></span><span> </span><span class="annot"><span class="annottext">OneShotInfo
</span><a href="#local-6989586621680867646"><span class="hs-identifier hs-var">one_shot</span></a></span><span>
</span><span id="line-1225"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
-&gt; [OneShotInfo]
-&gt; TCvSubst
-&gt; Type
-&gt; [EtaInfo]
-&gt; (InScopeSet, [EtaInfo])
</span><a href="#local-6989586621680867655"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867648"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; JoinArity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867645"><span class="hs-identifier hs-var">oss1</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867631"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867633"><span class="hs-identifier hs-var">res_ty</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; EtaInfo
</span><a href="GHC.Core.Opt.Arity.html#EtaVar"><span class="hs-identifier hs-var">EtaVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867627"><span class="hs-identifier hs-var">eta_id'</span></a></span><span> </span><span class="annot"><span class="annottext">EtaInfo -&gt; [EtaInfo] -&gt; [EtaInfo]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867642"><span class="hs-identifier hs-var">eis</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1226"></span><span>
</span><span id="line-1227"></span><span>       </span><span class="hs-comment">----------- Newtypes</span><span>
</span><span id="line-1228"></span><span>       </span><span class="hs-comment">-- Given this:</span><span>
</span><span id="line-1229"></span><span>       </span><span class="hs-comment">--      newtype T = MkT ([T] -&gt; Int)</span><span>
</span><span id="line-1230"></span><span>       </span><span class="hs-comment">-- Consider eta-expanding this</span><span>
</span><span id="line-1231"></span><span>       </span><span class="hs-comment">--      eta_expand 1 e T</span><span>
</span><span id="line-1232"></span><span>       </span><span class="hs-comment">-- We want to get</span><span>
</span><span id="line-1233"></span><span>       </span><span class="hs-comment">--      coerce T (\x::[T] -&gt; (coerce ([T]-&gt;Int) e) x)</span><span>
</span><span id="line-1234"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680867625"><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867625"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867624"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867624"><span class="hs-identifier hs-var">ty'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (CoercionR, Type)
</span><a href="GHC.Core.Coercion.html#topNormaliseNewType_maybe"><span class="hs-identifier hs-var">topNormaliseNewType_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867643"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1235"></span><span>       </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680867620"><span class="annot"><span class="annottext">co' :: CoercionR
</span><a href="#local-6989586621680867620"><span class="hs-identifier hs-var hs-var">co'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; CoercionR -&gt; CoercionR
TCvSubst -&gt; CoercionR -&gt; CoercionR
</span><a href="GHC.Core.TyCo.Subst.html#substCo"><span class="hs-identifier hs-var">Coercion.substCo</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867644"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867625"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-1236"></span><span>             </span><span class="hs-comment">-- Remember to apply the substitution to co (#16979)</span><span>
</span><span id="line-1237"></span><span>             </span><span class="hs-comment">-- (or we could have applied to ty, but then</span><span>
</span><span id="line-1238"></span><span>             </span><span class="hs-comment">--  we'd have had to zap it for the recursive call)</span><span>
</span><span id="line-1239"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
-&gt; [OneShotInfo]
-&gt; TCvSubst
-&gt; Type
-&gt; [EtaInfo]
-&gt; (InScopeSet, [EtaInfo])
</span><a href="#local-6989586621680867655"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867648"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">[OneShotInfo]
</span><a href="#local-6989586621680867647"><span class="hs-identifier hs-var">oss</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867644"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867624"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoercionR -&gt; [EtaInfo] -&gt; [EtaInfo]
</span><a href="GHC.Core.Opt.Arity.html#pushCoercion"><span class="hs-identifier hs-var">pushCoercion</span></a></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><a href="#local-6989586621680867620"><span class="hs-identifier hs-var">co'</span></a></span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867642"><span class="hs-identifier hs-var">eis</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1240"></span><span>
</span><span id="line-1241"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>       </span><span class="hs-comment">-- We have an expression of arity &gt; 0,</span><span>
</span><span id="line-1242"></span><span>                         </span><span class="hs-comment">-- but its type isn't a function, or a binder</span><span>
</span><span id="line-1243"></span><span>                         </span><span class="hs-comment">-- is levity-polymorphic</span><span>
</span><span id="line-1244"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">WARN</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">True</span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">orig_oss</span><span> </span><span class="hs-operator">&lt;+&gt;</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">orig_ty</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$$</span><span> </span><span class="hs-identifier">ppr_orig_expr</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-1245"></span><span>         </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; InScopeSet
</span><a href="GHC.Core.TyCo.Subst.html#getTCvInScope"><span class="hs-identifier hs-var">getTCvInScope</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867644"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[EtaInfo] -&gt; [EtaInfo]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[EtaInfo]
</span><a href="#local-6989586621680867642"><span class="hs-identifier hs-var">eis</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1246"></span><span>        </span><span class="hs-comment">-- This *can* legitimately happen:</span><span>
</span><span id="line-1247"></span><span>        </span><span class="hs-comment">-- e.g.  coerce Int (\x. x) Essentially the programmer is</span><span>
</span><span id="line-1248"></span><span>        </span><span class="hs-comment">-- playing fast and loose with types (Happy does this a lot).</span><span>
</span><span id="line-1249"></span><span>        </span><span class="hs-comment">-- So we simply decline to eta-expand.  Otherwise we'd end up</span><span>
</span><span id="line-1250"></span><span>        </span><span class="hs-comment">-- with an explicit lambda having a non-function type</span><span>
</span><span id="line-1251"></span><span>
</span><span id="line-1252"></span><span>
</span><span id="line-1253"></span><span>
</span><span id="line-1254"></span><span class="hs-comment">------------</span><span>
</span><span id="line-1255"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#subst_expr"><span class="hs-identifier hs-type">subst_expr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Subst.html#Subst"><span class="hs-identifier hs-type">Subst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>
</span><span id="line-1256"></span><span class="hs-comment">-- Apply a substitution to an expression.  We use substExpr</span><span>
</span><span id="line-1257"></span><span class="hs-comment">-- not substExprSC (short-cutting substitution) because</span><span>
</span><span id="line-1258"></span><span class="hs-comment">-- we may be changing the types of join points, so applying</span><span>
</span><span id="line-1259"></span><span class="hs-comment">-- the in-scope set is necessary.</span><span>
</span><span id="line-1260"></span><span class="hs-comment">--</span><span>
</span><span id="line-1261"></span><span class="hs-comment">-- ToDo: we could instead check if we actually *are*</span><span>
</span><span id="line-1262"></span><span class="hs-comment">-- changing any join points' types, and if not use substExprSC.</span><span>
</span><span id="line-1263"></span><span id="subst_expr"><span class="annot"><span class="annottext">subst_expr :: Subst -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Opt.Arity.html#subst_expr"><span class="hs-identifier hs-var hs-var">subst_expr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Subst -&gt; CoreExpr -&gt; CoreExpr
Subst -&gt; CoreExpr -&gt; CoreExpr
</span><a href="GHC.Core.Subst.html#substExpr"><span class="hs-identifier hs-var">substExpr</span></a></span><span>
</span><span id="line-1264"></span><span>
</span><span id="line-1265"></span><span>
</span><span id="line-1266"></span><span class="hs-comment">--------------</span><span>
</span><span id="line-1267"></span><span>
</span><span id="line-1268"></span><span class="hs-comment">-- | Split an expression into the given number of binders and a body,</span><span>
</span><span id="line-1269"></span><span class="hs-comment">-- eta-expanding if necessary. Counts value *and* type binders.</span><span>
</span><span id="line-1270"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaExpandToJoinPoint"><span class="hs-identifier hs-type">etaExpandToJoinPoint</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#JoinArity"><span class="hs-identifier hs-type">JoinArity</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1271"></span><span id="etaExpandToJoinPoint"><span class="annot"><span class="annottext">etaExpandToJoinPoint :: JoinArity -&gt; CoreExpr -&gt; ([Id], CoreExpr)
</span><a href="GHC.Core.Opt.Arity.html#etaExpandToJoinPoint"><span class="hs-identifier hs-var hs-var">etaExpandToJoinPoint</span></a></span></span><span> </span><span id="local-6989586621680867614"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867614"><span class="hs-identifier hs-var">join_arity</span></a></span></span><span> </span><span id="local-6989586621680867613"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867613"><span class="hs-identifier hs-var">expr</span></a></span></span><span>
</span><span id="line-1272"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; [Id] -&gt; CoreExpr -&gt; ([Id], CoreExpr)
</span><a href="#local-6989586621680867612"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867614"><span class="hs-identifier hs-var">join_arity</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867613"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-1273"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1274"></span><span>    </span><span id="local-6989586621680867612"><span class="annot"><span class="annottext">go :: JoinArity -&gt; [Id] -&gt; CoreExpr -&gt; ([Id], CoreExpr)
</span><a href="#local-6989586621680867612"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span> </span><span id="local-6989586621680867607"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867607"><span class="hs-identifier hs-var">rev_bs</span></a></span></span><span> </span><span id="local-6989586621680867606"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867606"><span class="hs-identifier hs-var">e</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; [Id]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867607"><span class="hs-identifier hs-var">rev_bs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867606"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1275"></span><span>    </span><span class="annot"><a href="#local-6989586621680867612"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621680867605"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867605"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621680867604"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867604"><span class="hs-identifier hs-var">rev_bs</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-type">Lam</span></a></span><span> </span><span id="local-6989586621680867603"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867603"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621680867602"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867602"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; [Id] -&gt; CoreExpr -&gt; ([Id], CoreExpr)
</span><a href="#local-6989586621680867612"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867605"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; JoinArity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867603"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; [Id]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867604"><span class="hs-identifier hs-var">rev_bs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867602"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-1276"></span><span>    </span><span class="annot"><a href="#local-6989586621680867612"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621680867601"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867601"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621680867600"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867600"><span class="hs-identifier hs-var">rev_bs</span></a></span></span><span> </span><span id="local-6989586621680867599"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867599"><span class="hs-identifier hs-var">e</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; CoreExpr -&gt; ([Id], CoreExpr)
</span><a href="GHC.Core.Opt.Arity.html#etaBodyForJoinPoint"><span class="hs-identifier hs-var">etaBodyForJoinPoint</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867601"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867599"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1277"></span><span>                              </span><span class="hs-special">(</span><span id="local-6989586621680867597"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867597"><span class="hs-identifier hs-var">bs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867596"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867596"><span class="hs-identifier hs-var">e'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; [Id]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867600"><span class="hs-identifier hs-var">rev_bs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Id] -&gt; [Id]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867597"><span class="hs-identifier hs-var">bs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867596"><span class="hs-identifier hs-var">e'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1278"></span><span>
</span><span id="line-1279"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaExpandToJoinPointRule"><span class="hs-identifier hs-type">etaExpandToJoinPointRule</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#JoinArity"><span class="hs-identifier hs-type">JoinArity</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreRule"><span class="hs-identifier hs-type">CoreRule</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreRule"><span class="hs-identifier hs-type">CoreRule</span></a></span><span>
</span><span id="line-1280"></span><span id="etaExpandToJoinPointRule"><span class="annot"><span class="annottext">etaExpandToJoinPointRule :: JoinArity -&gt; CoreRule -&gt; CoreRule
</span><a href="GHC.Core.Opt.Arity.html#etaExpandToJoinPointRule"><span class="hs-identifier hs-var hs-var">etaExpandToJoinPointRule</span></a></span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621680867595"><span class="annot"><span class="annottext">rule :: CoreRule
</span><a href="#local-6989586621680867595"><span class="hs-identifier hs-var">rule</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#BuiltinRule"><span class="hs-identifier hs-type">BuiltinRule</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1281"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">WARN</span><span class="hs-special">(</span><span class="hs-identifier">True</span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">sep</span><span> </span><span class="hs-special">[</span><span class="hs-identifier">text</span><span> </span><span class="hs-string">&quot;Can't eta-expand built-in rule:&quot;</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">rule</span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1282"></span><span>      </span><span class="hs-comment">-- How did a local binding get a built-in rule anyway? Probably a plugin.</span><span>
</span><span id="line-1283"></span><span>    </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680867595"><span class="hs-identifier hs-var">rule</span></a></span><span>
</span><span id="line-1284"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaExpandToJoinPointRule"><span class="hs-identifier hs-var">etaExpandToJoinPointRule</span></a></span><span> </span><span id="local-6989586621680867592"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867592"><span class="hs-identifier hs-var">join_arity</span></a></span></span><span> </span><span id="local-6989586621680867591"><span class="annot"><span class="annottext">rule :: CoreRule
</span><a href="#local-6989586621680867591"><span class="hs-identifier hs-var">rule</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Rule"><span class="hs-identifier hs-type">Rule</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ru_bndrs :: CoreRule -&gt; [Id]
</span><a href="GHC.Core.html#ru_bndrs"><span class="hs-identifier hs-var">ru_bndrs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680867588"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867588"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ru_rhs :: CoreRule -&gt; CoreExpr
</span><a href="GHC.Core.html#ru_rhs"><span class="hs-identifier hs-var">ru_rhs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680867586"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867586"><span class="hs-identifier hs-var">rhs</span></a></span></span><span>
</span><span id="line-1285"></span><span>                                               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ru_args :: CoreRule -&gt; [CoreExpr]
</span><a href="GHC.Core.html#ru_args"><span class="hs-identifier hs-var">ru_args</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680867584"><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680867584"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1286"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867583"><span class="hs-identifier hs-var">need_args</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span>
</span><span id="line-1287"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680867591"><span class="hs-identifier hs-var">rule</span></a></span><span>
</span><span id="line-1288"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867583"><span class="hs-identifier hs-var">need_args</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;</span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span>
</span><span id="line-1289"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; CoreRule
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;etaExpandToJoinPointRule&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867592"><span class="hs-identifier hs-var">join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680867591"><span class="hs-identifier hs-var">rule</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1290"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1291"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621680867591"><span class="hs-identifier hs-var">rule</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ru_bndrs :: [Id]
</span><a href="GHC.Core.html#ru_bndrs"><span class="hs-identifier hs-var">ru_bndrs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867588"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Id] -&gt; [Id]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867582"><span class="hs-identifier hs-var">new_bndrs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ru_args :: [CoreExpr]
</span><a href="GHC.Core.html#ru_args"><span class="hs-identifier hs-var">ru_args</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680867584"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr] -&gt; [CoreExpr] -&gt; [CoreExpr]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
forall {b}. [Expr b]
</span><a href="#local-6989586621680867581"><span class="hs-identifier hs-var">new_args</span></a></span><span>
</span><span id="line-1292"></span><span>         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ru_rhs :: CoreExpr
</span><a href="GHC.Core.html#ru_rhs"><span class="hs-identifier hs-var">ru_rhs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867580"><span class="hs-identifier hs-var">new_rhs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1293"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1294"></span><span>    </span><span id="local-6989586621680867583"><span class="annot"><span class="annottext">need_args :: JoinArity
</span><a href="#local-6989586621680867583"><span class="hs-identifier hs-var hs-var">need_args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867592"><span class="hs-identifier hs-var">join_arity</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; JoinArity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr] -&gt; JoinArity
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; JoinArity
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621680867584"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-1295"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680867582"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867582"><span class="hs-identifier hs-var">new_bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867580"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867580"><span class="hs-identifier hs-var">new_rhs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; CoreExpr -&gt; ([Id], CoreExpr)
</span><a href="GHC.Core.Opt.Arity.html#etaBodyForJoinPoint"><span class="hs-identifier hs-var">etaBodyForJoinPoint</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867583"><span class="hs-identifier hs-var">need_args</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867586"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1296"></span><span>    </span><span id="local-6989586621680867581"><span class="annot"><span class="annottext">new_args :: [Expr b]
</span><a href="#local-6989586621680867581"><span class="hs-identifier hs-var hs-var">new_args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Expr b]
forall b. [Id] -&gt; [Expr b]
</span><a href="GHC.Core.html#varsToCoreExprs"><span class="hs-identifier hs-var">varsToCoreExprs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867582"><span class="hs-identifier hs-var">new_bndrs</span></a></span><span>
</span><span id="line-1297"></span><span>
</span><span id="line-1298"></span><span class="hs-comment">-- Adds as many binders as asked for; assumes expr is not a lambda</span><span>
</span><span id="line-1299"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#etaBodyForJoinPoint"><span class="hs-identifier hs-type">etaBodyForJoinPoint</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBndr"><span class="hs-identifier hs-type">CoreBndr</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1300"></span><span id="etaBodyForJoinPoint"><span class="annot"><span class="annottext">etaBodyForJoinPoint :: JoinArity -&gt; CoreExpr -&gt; ([Id], CoreExpr)
</span><a href="GHC.Core.Opt.Arity.html#etaBodyForJoinPoint"><span class="hs-identifier hs-var hs-var">etaBodyForJoinPoint</span></a></span></span><span> </span><span id="local-6989586621680867576"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867576"><span class="hs-identifier hs-var">need_args</span></a></span></span><span> </span><span id="local-6989586621680867575"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867575"><span class="hs-identifier hs-var">body</span></a></span></span><span>
</span><span id="line-1301"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity
-&gt; Type -&gt; TCvSubst -&gt; [Id] -&gt; CoreExpr -&gt; ([Id], CoreExpr)
forall {b}.
JoinArity -&gt; Type -&gt; TCvSubst -&gt; [Id] -&gt; Expr b -&gt; ([Id], Expr b)
</span><a href="#local-6989586621680867574"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867576"><span class="hs-identifier hs-var">need_args</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; Type
</span><a href="GHC.Core.Utils.html#exprType"><span class="hs-identifier hs-var">exprType</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867575"><span class="hs-identifier hs-var">body</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; TCvSubst
</span><a href="#local-6989586621680867573"><span class="hs-identifier hs-var">init_subst</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867575"><span class="hs-identifier hs-var">body</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867575"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-1302"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1303"></span><span>    </span><span id="local-6989586621680867574"><span class="annot"><span class="annottext">go :: JoinArity -&gt; Type -&gt; TCvSubst -&gt; [Id] -&gt; Expr b -&gt; ([Id], Expr b)
</span><a href="#local-6989586621680867574"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span>  </span><span class="annot"><span class="annottext">TCvSubst
</span><span class="hs-identifier">_</span></span><span>     </span><span id="local-6989586621680867561"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867561"><span class="hs-identifier hs-var">rev_bs</span></a></span></span><span> </span><span id="local-6989586621680867560"><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680867560"><span class="hs-identifier hs-var">e</span></a></span></span><span>
</span><span id="line-1304"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; [Id]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867561"><span class="hs-identifier hs-var">rev_bs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680867560"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1305"></span><span>    </span><span class="annot"><a href="#local-6989586621680867574"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621680867559"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867559"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621680867558"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867558"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621680867557"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867557"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680867556"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867556"><span class="hs-identifier hs-var">rev_bs</span></a></span></span><span> </span><span id="local-6989586621680867555"><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680867555"><span class="hs-identifier hs-var">e</span></a></span></span><span>
</span><span id="line-1306"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680867554"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867554"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867553"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867553"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (Id, Type)
</span><a href="GHC.Core.Type.html#splitForAllTy_maybe"><span class="hs-identifier hs-var">splitForAllTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867558"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1307"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680867550"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867550"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867549"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867549"><span class="hs-identifier hs-var">tv'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Id -&gt; (TCvSubst, Id)
TCvSubst -&gt; Id -&gt; (TCvSubst, Id)
</span><a href="GHC.Core.TyCo.Subst.html#substVarBndr"><span class="hs-identifier hs-var">Type.substVarBndr</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867557"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867554"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-1308"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; Type -&gt; TCvSubst -&gt; [Id] -&gt; Expr b -&gt; ([Id], Expr b)
</span><a href="#local-6989586621680867574"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867559"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; JoinArity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867553"><span class="hs-identifier hs-var">res_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867550"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867549"><span class="hs-identifier hs-var">tv'</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; [Id]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867556"><span class="hs-identifier hs-var">rev_bs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680867555"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">Expr b -&gt; Expr b -&gt; Expr b
forall b. Expr b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#App"><span class="hs-operator hs-var">`App`</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Expr b
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#varToCoreExpr"><span class="hs-identifier hs-var">varToCoreExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867549"><span class="hs-identifier hs-var">tv'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1309"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680867548"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867548"><span class="hs-identifier hs-var">mult</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867547"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867547"><span class="hs-identifier hs-var">arg_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867546"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867546"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (Type, Type, Type)
</span><a href="GHC.Core.Type.html#splitFunTy_maybe"><span class="hs-identifier hs-var">splitFunTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867558"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1310"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680867545"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867545"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680867544"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867544"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; TCvSubst -&gt; Scaled Type -&gt; (TCvSubst, Id)
</span><a href="GHC.Core.Opt.Arity.html#freshEtaId"><span class="hs-identifier hs-var">freshEtaId</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867559"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867557"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Scaled Type
forall a. Type -&gt; a -&gt; Scaled a
</span><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-var">Scaled</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867548"><span class="hs-identifier hs-var">mult</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867547"><span class="hs-identifier hs-var">arg_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1311"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; Type -&gt; TCvSubst -&gt; [Id] -&gt; Expr b -&gt; ([Id], Expr b)
</span><a href="#local-6989586621680867574"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867559"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">JoinArity -&gt; JoinArity -&gt; JoinArity
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">JoinArity
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867546"><span class="hs-identifier hs-var">res_ty</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867545"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867544"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; [Id]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680867556"><span class="hs-identifier hs-var">rev_bs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Expr b
</span><a href="#local-6989586621680867555"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">Expr b -&gt; Expr b -&gt; Expr b
forall b. Expr b -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#App"><span class="hs-operator hs-var">`App`</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Expr b
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867544"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1312"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1313"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; ([Id], Expr b)
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;etaBodyForJoinPoint&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; ([Id], Expr b)) -&gt; SDoc -&gt; ([Id], Expr b)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#int"><span class="hs-identifier hs-var">int</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867576"><span class="hs-identifier hs-var">need_args</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span>
</span><span id="line-1314"></span><span>                                         </span><span class="annot"><span class="annottext">CoreExpr -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867575"><span class="hs-identifier hs-var">body</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; Type
</span><a href="GHC.Core.Utils.html#exprType"><span class="hs-identifier hs-var">exprType</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867575"><span class="hs-identifier hs-var">body</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1315"></span><span>
</span><span id="line-1316"></span><span>    </span><span id="local-6989586621680867573"><span class="annot"><span class="annottext">init_subst :: CoreExpr -&gt; TCvSubst
</span><a href="#local-6989586621680867573"><span class="hs-identifier hs-var hs-var">init_subst</span></a></span></span><span> </span><span id="local-6989586621680867542"><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867542"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkEmptyTCvSubst"><span class="hs-identifier hs-var">mkEmptyTCvSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IdSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier hs-var">mkInScopeSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreExpr -&gt; IdSet
</span><a href="GHC.Core.FVs.html#exprFreeVars"><span class="hs-identifier hs-var">exprFreeVars</span></a></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621680867542"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1317"></span><span>
</span><span id="line-1318"></span><span class="hs-comment">--------------</span><span>
</span><span id="line-1319"></span><span class="annot"><a href="GHC.Core.Opt.Arity.html#freshEtaId"><span class="hs-identifier hs-type">freshEtaId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1320"></span><span class="hs-comment">-- Make a fresh Id, with specified type (after applying substitution)</span><span>
</span><span id="line-1321"></span><span class="hs-comment">-- It should be &quot;fresh&quot; in the sense that it's not in the in-scope set</span><span>
</span><span id="line-1322"></span><span class="hs-comment">-- of the TvSubstEnv; and it should itself then be added to the in-scope</span><span>
</span><span id="line-1323"></span><span class="hs-comment">-- set of the TvSubstEnv</span><span>
</span><span id="line-1324"></span><span class="hs-comment">--</span><span>
</span><span id="line-1325"></span><span class="hs-comment">-- The Int is just a reasonable starting point for generating a unique;</span><span>
</span><span id="line-1326"></span><span class="hs-comment">-- it does not necessarily have to be unique itself.</span><span>
</span><span id="line-1327"></span><span id="freshEtaId"><span class="annot"><span class="annottext">freshEtaId :: JoinArity -&gt; TCvSubst -&gt; Scaled Type -&gt; (TCvSubst, Id)
</span><a href="GHC.Core.Opt.Arity.html#freshEtaId"><span class="hs-identifier hs-var hs-var">freshEtaId</span></a></span></span><span> </span><span id="local-6989586621680867541"><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867541"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621680867540"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867540"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621680867539"><span class="annot"><span class="annottext">Scaled Type
</span><a href="#local-6989586621680867539"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-1328"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867538"><span class="hs-identifier hs-var">subst'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867537"><span class="hs-identifier hs-var">eta_id'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1329"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-1330"></span><span>        </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span id="local-6989586621680867534"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867534"><span class="hs-identifier hs-var">mult'</span></a></span></span><span> </span><span id="local-6989586621680867533"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867533"><span class="hs-identifier hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Scaled Type -&gt; Scaled Type
TCvSubst -&gt; Scaled Type -&gt; Scaled Type
</span><a href="GHC.Core.TyCo.Subst.html#substScaledTyUnchecked"><span class="hs-identifier hs-var">Type.substScaledTyUnchecked</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867540"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Scaled Type
</span><a href="#local-6989586621680867539"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-1331"></span><span>        </span><span id="local-6989586621680867537"><span class="annot"><span class="annottext">eta_id' :: Id
</span><a href="#local-6989586621680867537"><span class="hs-identifier hs-var hs-var">eta_id'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; Id -&gt; Id
</span><a href="GHC.Types.Var.Env.html#uniqAway"><span class="hs-identifier hs-var">uniqAway</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; InScopeSet
</span><a href="GHC.Core.TyCo.Subst.html#getTCvInScope"><span class="hs-identifier hs-var">getTCvInScope</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867540"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Id) -&gt; Id -&gt; Id
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1332"></span><span>                  </span><span class="annot"><span class="annottext">FastString -&gt; Unique -&gt; Type -&gt; Type -&gt; Id
</span><a href="GHC.Types.Id.html#mkSysLocalOrCoVar"><span class="hs-identifier hs-var">mkSysLocalOrCoVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; FastString
</span><a href="GHC.Data.FastString.html#fsLit"><span class="hs-identifier hs-var">fsLit</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;eta&quot;</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">JoinArity -&gt; Unique
</span><a href="GHC.Types.Unique.html#mkBuiltinUnique"><span class="hs-identifier hs-var">mkBuiltinUnique</span></a></span><span> </span><span class="annot"><span class="annottext">JoinArity
</span><a href="#local-6989586621680867541"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867534"><span class="hs-identifier hs-var">mult'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680867533"><span class="hs-identifier hs-var">ty'</span></a></span><span>
</span><span id="line-1333"></span><span>                  </span><span class="hs-comment">-- &quot;OrCoVar&quot; since this can be used to eta-expand</span><span>
</span><span id="line-1334"></span><span>                  </span><span class="hs-comment">-- coercion abstractions</span><span>
</span><span id="line-1335"></span><span>        </span><span id="local-6989586621680867538"><span class="annot"><span class="annottext">subst' :: TCvSubst
</span><a href="#local-6989586621680867538"><span class="hs-identifier hs-var hs-var">subst'</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Id -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTCvInScope"><span class="hs-identifier hs-var">extendTCvInScope</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621680867540"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680867537"><span class="hs-identifier hs-var">eta_id'</span></a></span><span>
</span><span id="line-1336"></span></pre></body></html>